<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Assistentes de Visualiza&ccedil;&atilde;o - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.view.helpers.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.view.helpers.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.view.scripts.html">Scripts de Visualiza&ccedil;&atilde;o</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.view.html">Zend_View</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.view.abstract.html">Zend_View_Abstract</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.view.helpers" class="section"><div class="info"><h1 class="title">Assistentes de Visualização</h1></div>
    

    <p class="para">
        Em seus scripts de visualização, frequentemente é necessário a execução de certas tarefas
        complexas repetidas vezes: p. ex.: formatar uma data, gerar um elemento de formulário, ou
        exibir links de acionamento. Você pode empregar classes assistentes para executar estas
        tarefas para você.
    </p>

    <p class="para">
        A helper is simply a class. Let&#039;s say we want a helper named &#039;fooBar&#039;.
        By default, the class is prefixed with &#039;Zend_View_Helper_&#039;
        (you can specify a custom prefix when setting a helper path), and the
        last segment of the class name is the helper name; this segment should
        be TitleCapped; the full class name is then:
        <span class="classname">Zend_View_Helper_FooBar</span>. This class should contain at the
        minimum a single method, named after the helper, and camelCased:
         <span class="methodname">fooBar()</span>.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Watch the Case</b><br /></span>
        

        <p class="para">
            Helper names are always camelCased, i.e., they never begin with an
            uppercase character. The class name itself is MixedCased, but the
            method that is actually executed is camelCased.
        </p>
    </p></blockquote>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Default Helper Path</b><br /></span>
        

        <p class="para">
            The default helper path always points to the Zend Framework view
            helpers, i.e., &#039;Zend/View/Helper/&#039;. Even if you call
             <span class="methodname">setHelperPath()</span> to overwrite the existing paths, this
            path will be set to ensure the default helpers work.
        </p>
    </p></blockquote>

    <p class="para">
        Para usar um assistente em seu script de visualização, chame-o usando
        <strong class="command">$this-&gt;helperName()</strong>. Em segundo plano, <span class="classname">Zend_View</span>
        irá carregar a classe <span class="classname">Zend_View_Helper_HelperName</span>, instanciá-la e
        chamar seu método  <span class="methodname">helperName()</span>. O objeto criado é persistente
        dentro do escopo da instância <span class="classname">Zend_View</span>, e será reutilizado por todas
        as chamadas futuras a <strong class="command">$this-&gt;helperName()</strong>.
    </p>

    <div class="section" id="zend.view.helpers.initial"><div class="info"><h1 class="title">Assistentes Padrão</h1></div>
        

        <p class="para">
            <span class="classname">Zend_View</span> vem com um conjunto padrão de assistentes, a maioria
            deles dedicados à geração de elementos de formulários e automaticamente escapar a saída
            apropriada. Além disso, existem assistentes para criar <acronym class="acronym">URL</acronym>s baseadas
            em rotas e listas de <acronym class="acronym">HTML</acronym>, bem como declarar variáveis. Os
            assistentes atualmente embarcados incluem:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                     <span class="methodname">declareVars()</span>: Primarily for use when using
                     <span class="methodname">strictVars()</span>, this helper can be used to declare
                    template variables that may or may not already be set in the
                    view object, as well as to set default values. Arrays passed as
                    arguments to the method will be used to set default values;
                    otherwise, if the variable does not exist, it is set to an empty string.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">fieldset($name, $content, $attribs)</span>: Creates an
                    <acronym class="acronym">XHTML</acronym> fieldset. If <var class="varname">$attribs</var> contains a
                    &#039;legend&#039; key, that value will be used for the fieldset legend. The
                    fieldset will surround the <var class="varname">$content</var> as provided to
                    the helper.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">form($name, $attribs, $content)</span>: Generates an
                    <acronym class="acronym">XHTML</acronym> form. All <var class="varname">$attribs</var> are escaped and
                    rendered as <acronym class="acronym">XHTML</acronym> attributes of the form tag. If
                    <var class="varname">$content</var> is present and not a boolean
                    <b><tt>FALSE</tt></b>, then that content is rendered within the start and
                    close form tags; if <var class="varname">$content</var> is a boolean
                    <b><tt>FALSE</tt></b> (the default), only the opening form tag is
                    generated.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formButton($name, $value, $attribs)</span>: Cria um elemento
                    &lt;button /&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formCheckbox($name, $value, $attribs, $options)</span>:
                    Cria um elemento &lt;input type=&quot;checkbox&quot; /&gt;.
                </p>

                <p class="para">
                    By default, when no $value is provided and no $options are
                    present, &#039;0&#039; is assumed to be the unchecked value, and &#039;1&#039;
                    the checked value. If a $value is passed, but no $options
                    are present, the checked value is assumed to be the value
                    passed.
                </p>

                <p class="para">
                    $options should be an array. If the array is indexed, the
                    first value is the checked value, and the second the
                    unchecked value; all other values are ignored. You may also
                    pass an associative array with the keys &#039;checked&#039; and
                    &#039;unChecked&#039;.
                </p>

                <p class="para">
                    If $options has been passed, if $value matches the checked
                    value, then the element will be marked as checked. You may
                    also mark the element as checked or unchecked by passing a
                    boolean value for the attribute &#039;checked&#039;.
                </p>

                <p class="para">
                    The above is probably best summed up with some examples:
                </p>

                <pre class="programlisting brush: php">
// &#039;1&#039; and &#039;0&#039; as checked/unchecked options; not checked
echo $this-&gt;formCheckbox(&#039;foo&#039;);

// &#039;1&#039; and &#039;0&#039; as checked/unchecked options; checked
echo $this-&gt;formCheckbox(&#039;foo&#039;, null, array(&#039;checked&#039; =&gt; true));

// &#039;bar&#039; and &#039;0&#039; as checked/unchecked options; not checked
echo $this-&gt;formCheckbox(&#039;foo&#039;, &#039;bar&#039;);

// &#039;bar&#039; and &#039;0&#039; as checked/unchecked options; checked
echo $this-&gt;formCheckbox(&#039;foo&#039;, &#039;bar&#039;, array(&#039;checked&#039; =&gt; true));

// &#039;bar&#039; and &#039;baz&#039; as checked/unchecked options; unchecked
echo $this-&gt;formCheckbox(&#039;foo&#039;, null, null, array(&#039;bar&#039;, &#039;baz&#039;));

// &#039;bar&#039; and &#039;baz&#039; as checked/unchecked options; unchecked
echo $this-&gt;formCheckbox(&#039;foo&#039;, null, null, array(
    &#039;checked&#039; =&gt; &#039;bar&#039;,
    &#039;unChecked&#039; =&gt; &#039;baz&#039;
));

// &#039;bar&#039; and &#039;baz&#039; as checked/unchecked options; checked
echo $this-&gt;formCheckbox(&#039;foo&#039;, &#039;bar&#039;, null, array(&#039;bar&#039;, &#039;baz&#039;));
echo $this-&gt;formCheckbox(&#039;foo&#039;,
                         null,
                         array(&#039;checked&#039; =&gt; true),
                         array(&#039;bar&#039;, &#039;baz&#039;));

// &#039;bar&#039; and &#039;baz&#039; as checked/unchecked options; unchecked
echo $this-&gt;formCheckbox(&#039;foo&#039;, &#039;baz&#039;, null, array(&#039;bar&#039;, &#039;baz&#039;));
echo $this-&gt;formCheckbox(&#039;foo&#039;,
                         null,
                         array(&#039;checked&#039; =&gt; false),
                         array(&#039;bar&#039;, &#039;baz&#039;));
</pre>


                <p class="para">
                    In all cases, the markup prepends a hidden element with the
                    unchecked value; this way, if the value is unchecked, you
                    will still get a valid value returned to your form.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formErrors($errors, $options)</span>: Generates an
                    <acronym class="acronym">XHTML</acronym> unordered list to show errors.
                    <var class="varname">$errors</var> should be a string or an array of strings;
                    <var class="varname">$options</var> should be any attributes you want
                    placed in the opening list tag.
                </p>

                <p class="para">
                    You can specify alternate opening, closing, and separator
                    content when rendering the errors by calling several methods
                    on the helper:
                </p>

                <ul class="itemizedlist">
                    <li class="listitem">
                        <p class="para">
                             <span class="methodname">setElementStart($string)</span>; default is
                            &#039;&lt;ul class=&quot;errors&quot;%s&quot;&gt;&lt;li&gt;&#039;, where %s
                            is replaced with the attributes as specified in
                            <var class="varname">$options</var>.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                             <span class="methodname">setElementSeparator($string)</span>; default
                            is &#039;&lt;/li&gt;&lt;li&gt;&#039;.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                             <span class="methodname">setElementEnd($string)</span>; default is
                            &#039;&lt;/li&gt;&lt;/ul&gt;&#039;.
                        </p>
                    </li>
                </ul>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formFile($name, $attribs)</span>: Cria um elemento
                    &lt;input type=&quot;file&quot; /&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formHidden($name, $value, $attribs)</span>: Cria um elemento
                    &lt;input type=&quot;hidden&quot; /&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formLabel($name, $value, $attribs)</span>: Creates a
                    &lt;label&gt; element, setting the <span class="property">for</span> attribute to
                    <var class="varname">$name</var>, and the actual label text to
                    <var class="varname">$value</var>. If <em class="emphasis">disable</em> is passed in
                    <span class="property">attribs</span>, nothing will be returned.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formMultiCheckbox($name, $value, $attribs, $options,
                        $listsep)</span>: Creates a list of checkboxes.
                    <var class="varname">$options</var> should be an associative array, and may be
                    arbitrarily deep. <var class="varname">$value</var> may be a single value or
                    an array of selected values that match the keys in the
                    <var class="varname">$options</var> array. <var class="varname">$listsep</var> is an
                    <acronym class="acronym">HTML</acronym> break (&quot;&lt;br /&gt;&quot;) by default. By default, this
                    element is treated as an array; all checkboxes share the same name, and are
                    submitted as an array.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formPassword($name, $value, $attribs)</span>: Cria um elemento
                    &lt;input type=&quot;password&quot; /&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formRadio($name, $value, $attribs, $options)</span>: Cria uma
                    série de elementos &lt;input type=&quot;radio&quot; /&gt;, um para cada elemento em
                    $options. Na matriz $options, a chave e seu valor estão associados ao valor do
                    controle e seu rótulo, respectivamente. O conteúdo de $value será
                    pré-selecionado.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formReset($name, $value, $attribs)</span>: Cria um elemento
                    &lt;input type=&quot;reset&quot; /&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formSelect($name, $value, $attribs, $options)</span>: Cria um
                    bloco &lt;select&gt;...&lt;/select&gt;, com um &lt;option&gt; para cada elemento
                    em $options. Na matriz $options, a chave e seu valor estão associados ao valor
                    do controle e seu rótulo. O conteúdo de $value será pré-selecionado.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formSubmit($name, $value, $attribs)</span>: Cria um elemento
                    &lt;input type=&quot;submit&quot; /&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formText($name, $value, $attribs)</span>: Cria um elemento
                    &lt;input type=&quot;text&quot; /&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">formTextarea($name, $value, $attribs)</span>: Cria um bloco
                    &lt;textarea&gt;...&lt;/textarea&gt;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">url($urlOptions, $name, $reset)</span>: Creates a
                    <acronym class="acronym">URL</acronym> string based on a named route.
                    <var class="varname">$urlOptions</var> should be an associative array of key/value pairs
                    used by the particular route.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">htmlList($items, $ordered, $attribs, $escape)</span>:
                    generates unordered and ordered lists based on the <var class="varname">$items</var>
                    passed to it. If <var class="varname">$items</var> is a multidimensional
                    array, a nested list will be built. If the <var class="varname">$escape</var>
                    flag is <b><tt>TRUE</tt></b> (default), individual items will be escaped
                    using the view objects registered escaping mechanisms; pass a
                    <b><tt>FALSE</tt></b> value if you want to allow markup in your lists.
                </p>
            </li>
        </ul>

        <p class="para">
            Utilizar estes assistentes em seus scripts de visualização é muito fácil, aqui está um
            exemplo. Note que tudo que você necessita fazer é chamá-los; eles carregam e instanciam
            a sí próprios a medida que tornam-se necessários.
        </p>

        <pre class="programlisting brush: php">
// dentro do seu script de visualização,
// $this aponta para a instância de Zend_View.
//
// digamos que você já atribuiu uma série de valores a matriz
// $countries = array(&#039;us&#039; =&gt; &#039;United States&#039;, &#039;il&#039; =&gt;
// &#039;Israel&#039;, &#039;de&#039; =&gt; &#039;Germany&#039;).
?&gt;
&lt;form action=&quot;action.php&quot; method=&quot;post&quot;&gt;
    &lt;p&gt;&lt;label&gt;Your Email:
&lt;?php echo $this-&gt;formText(&#039;email&#039;, &#039;you@example.com&#039;, array(&#039;size&#039; =&gt; 32)) ?&gt;
    &lt;/label&gt;&lt;/p&gt;
    &lt;p&gt;&lt;label&gt;Your Country:
&lt;?php echo $this-&gt;formSelect(&#039;country&#039;, &#039;us&#039;, null, $this-&gt;countries) ?&gt;
    &lt;/label&gt;&lt;/p&gt;
    &lt;p&gt;&lt;label&gt;Would you like to opt in?
&lt;?php echo $this-&gt;formCheckbox(&#039;opt_in&#039;, &#039;yes&#039;, null, array(&#039;yes&#039;, &#039;no&#039;)) ?&gt;
    &lt;/label&gt;&lt;/p&gt;
&lt;/form&gt;
</pre>


        <p class="para">
            A saída resultante do script de visualização deverá se parecer com isto:
        </p>

        <pre class="programlisting brush: php">
&lt;form action=&quot;action.php&quot; method=&quot;post&quot;&gt;
    &lt;p&gt;&lt;label&gt;Your Email:
        &lt;input type=&quot;text&quot; name=&quot;email&quot; value=&quot;you@example.com&quot; size=&quot;32&quot; /&gt;
    &lt;/label&gt;&lt;/p&gt;
    &lt;p&gt;&lt;label&gt;Your Country:
        &lt;select name=&quot;country&quot;&gt;
            &lt;option value=&quot;us&quot; selected=&quot;selected&quot;&gt;United States&lt;/option&gt;
            &lt;option value=&quot;il&quot;&gt;Israel&lt;/option&gt;
            &lt;option value=&quot;de&quot;&gt;Germany&lt;/option&gt;
        &lt;/select&gt;
    &lt;/label&gt;&lt;/p&gt;
    &lt;p&gt;&lt;label&gt;Would you like to opt in?
        &lt;input type=&quot;hidden&quot; name=&quot;opt_in&quot; value=&quot;no&quot; /&gt;
        &lt;input type=&quot;checkbox&quot; name=&quot;opt_in&quot; value=&quot;yes&quot; checked=&quot;checked&quot; /&gt;
    &lt;/label&gt;&lt;/p&gt;
&lt;/form&gt;
</pre>


        <div class="section" id="zend.view.helpers.initial.action"><div class="info"><h1 class="title">Action View Helper</h1></div>
    

    <p class="para">
        The <span class="classname">Action</span> view helper enables view scripts to dispatch a
        given controller action; the result of the response object following the
        dispatch is then returned. These can be used when a particular action
        could generate re-usable content or &quot;widget-ized&quot; content.
    </p>

    <p class="para">
        Actions that result in a  <span class="methodname">_forward()</span> or redirect are
        considered invalid, and will return an empty string.
    </p>

    <p class="para">
        The <acronym class="acronym">API</acronym> for the <span class="classname">Action</span> view helper follows that of
        most <acronym class="acronym">MVC</acronym> components that invoke controller actions:
        <strong class="command">action($action, $controller, $module = null, array $params = array())</strong>.
        <var class="varname">$action</var> and <var class="varname">$controller</var> are required; if no
        module is specified, the default module is assumed.
    </p>

    <div class="example" id="zend.view.helpers.initial.action.usage"><div class="info"><p><b>Example #1 Basic Usage of Action View Helper</b></p></div>
        

        <div class="example-contents"><p>
            As an example, you may have a <span class="classname">CommentController</span> with a
             <span class="methodname">listAction()</span> method you wish to invoke in order to pull
            a list of comments for the current request:
        </p></div>

        <pre class="programlisting brush: php">
&lt;div id=&quot;sidebar right&quot;&gt;
    &lt;div class=&quot;item&quot;&gt;
        &lt;?php echo $this-&gt;action(&#039;list&#039;,
                                 &#039;comment&#039;,
                                 null,
                                 array(&#039;count&#039; =&gt; 10)); ?&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre>

    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.baseurl"><div class="info"><h1 class="title">BaseUrl Helper</h1></div>
    

    <p class="para">
        While most <acronym class="acronym">URL</acronym>s generated by the framework have the base
        <acronym class="acronym">URL</acronym> prepended automatically, developers will need to prepend the
        base <acronym class="acronym">URL</acronym> to their own <acronym class="acronym">URL</acronym>s in order for paths
        to resources to be correct.
    </p>

    <p class="para">
        Usage of the BaseUrl helper is very straightforward:
    </p>

    <pre class="programlisting brush: php">
/*
 * The following assume that the base URL of the page/application is &quot;/mypage&quot;.
 */

/*
 * Prints:
 * &lt;base href=&quot;/mypage/&quot; /&gt;
 */
&lt;base href=&quot;&lt;?php echo $this-&gt;baseUrl(); ?&gt;&quot; /&gt;

/*
 * Prints:
 * &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/mypage/css/base.css&quot; /&gt;
 */
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot;
     href=&quot;&lt;?php echo $this-&gt;baseUrl(&#039;css/base.css&#039;); ?&gt;&quot; /&gt;
</pre>


    <blockquote class="note"><p><b class="note">Note</b>: 
        <p class="para">
            For simplicity&#039;s sake, we strip out the entry <acronym class="acronym">PHP</acronym> file (e.g.,
            &quot;<var class="filename">index.php</var>&quot;) from the base <acronym class="acronym">URL</acronym> that was
            contained in <span class="classname">Zend_Controller</span>. However, in some situations
            this may cause a problem. If one occurs, use
             <span class="methodname">$this-&gt;getHelper(&#039;BaseUrl&#039;)-&gt;setBaseUrl()</span> to set your
            own BaseUrl.
        </p>
    </p></blockquote>
</div>
        <div class="section" id="zend.view.helpers.initial.currency"><div class="info"><h1 class="title">Currency Helper</h1></div>
    

    <p class="para">
        Displaying localized currency values is a common task; the
        <span class="classname">Zend_Currency</span> view helper is intended to simply this task. See the
        <a href="zend.currency.introduction.html" class="link">Zend_Currency documentation</a> for specifics
        on this localization feature. In this section, we will focus simply on usage of the view
        helper.
    </p>

    <p class="para">
        There are several ways to initiate the <em class="emphasis">Currency</em> view helper:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                Registered, through a previously registered instance in
                <span class="classname">Zend_Registry</span>.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                Afterwards, through the fluent interface.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                Directly, through instantiating the class.
            </p>
        </li>
    </ul>

    <p class="para">
        A registered instance of <span class="classname">Zend_Currency</span> is the preferred usage for
        this helper. Doing so, you can select the currency to be used prior to adding the adapter to
        the registry.
    </p>

    <p class="para">
        There are several ways to select the desired currency. First, you may simply provide a
        currency string; alternately, you may specify a locale. The preferred way is to use a
        locale as this information is automatically detected and selected via the
        <acronym class="acronym">HTTP</acronym> client headers provided when a user accesses your application, and
        ensures the currency provided will match their locale.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: 
        <p class="para">
            We are speaking of &quot;locales&quot; instead of &quot;languages&quot; because a language may vary based on
            the geographical region in which it is used. For example, English is spoken in different
            dialects: British English, American English, etc. As a currency always correlates to a
            country you must give a fully-qualified locale, which means providing both the language
            <em class="emphasis">and</em> region. Therefore, we say &quot;locale&quot; instead of &quot;language.&quot;
        </p>
    </p></blockquote>

    <div class="example" id="zend.view.helpers.initial.currency.registered"><div class="info"><p><b>Example #2 Registered instance</b></p></div>
        

        <div class="example-contents"><p>
            To use a registered instance, simply create an instance of
            <span class="classname">Zend_Currency</span> and register it within
            <span class="classname">Zend_Registry</span> using <span class="classname">Zend_Currency</span> as its
            key.
        </p></div>

        <pre class="programlisting brush: php">
// our example currency
$currency = new Zend_Currency(&#039;de_AT&#039;);
Zend_Registry::set(&#039;Zend_Currency&#039;, $currency);

// within your view
echo $this-&gt;currency(1234.56);
// this returns &#039;€ 1.234,56&#039;
</pre>

    </div>

    <p class="para">
        If you are more familiar with the fluent interface, then you can also create an instance
        within your view and configure the helper afterwards.
    </p>

    <div class="example" id="zend.view.helpers.initial.currency.afterwards"><div class="info"><p><b>Example #3 Within the view</b></p></div>
        

        <div class="example-contents"><p>
            To use the fluent interface, create an instance of <span class="classname">Zend_Currency</span>,
            call the helper without a parameter, and call the  <span class="methodname">setCurrency()</span>
            method.
        </p></div>

        <pre class="programlisting brush: php">
// within your view
$currency = new Zend_Currency(&#039;de_AT&#039;);
$this-&gt;currency()-&gt;setCurrency($currency)-&gt;currency(1234.56);
// this returns &#039;€ 1.234,56&#039;
</pre>

    </div>

    <p class="para">
        If you are using the helper without <span class="classname">Zend_View</span> then you can
        also use it directly.
    </p>

    <div class="example" id="zend.view.helpers.initial.currency.directly.example-1"><div class="info"><p><b>Example #4 Direct usage</b></p></div>
        

        <pre class="programlisting brush: php">
// our example currency
$currency = new Zend_Currency(&#039;de_AT&#039;);

// initiate the helper
$helper = new Zend_View_Helper_Currency($currency);
echo $helper-&gt;currency(1234.56); // this returns &#039;€ 1.234,56&#039;
</pre>

    </div>

    <p class="para">
        As already seen, the  <span class="methodname">currency()</span> method is used to return the
        currency string. Just call it with the value you want to display as a currency. It also
        accepts some options which may be used to change the behaviour and output of the helper.
    </p>

    <div class="example" id="zend.view.helpers.initial.currency.directly.example-2"><div class="info"><p><b>Example #5 Direct usage</b></p></div>
        

        <pre class="programlisting brush: php">
// our example currency
$currency = new Zend_Currency(&#039;de_AT&#039;);

// initiate the helper
$helper = new Zend_View_Helper_Currency($currency);
echo $helper-&gt;currency(1234.56); // this returns &#039;€ 1.234,56&#039;
echo $helper-&gt;currency(1234.56, array(&#039;precision&#039; =&gt; 1));
// this returns &#039;€ 1.234,6&#039;
</pre>

    </div>

    <p class="para">
        For details about the available options, search for <span class="classname">Zend_Currency</span>&#039;s
         <span class="methodname">toCurrency()</span> method.
    </p>
</div>
        <div class="section" id="zend.view.helpers.initial.cycle"><div class="info"><h1 class="title">Cycle Helper</h1></div>
    

    <p class="para">
        The <span class="classname">Cycle</span> helper is used to alternate a set of values.
    </p>

    <div class="example" id="zend.view.helpers.initial.cycle.basicusage"><div class="info"><p><b>Example #6 Cycle Helper Basic Usage</b></p></div>
        

        <div class="example-contents"><p>
            To add elements to cycle just specify them in constructor
            or use  <span class="methodname">assign(array $data)</span> function
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php foreach ($this-&gt;books as $book):?&gt;
  &lt;tr style=&quot;background-color:&lt;?php echo $this-&gt;cycle(array(&quot;#F0F0F0&quot;,
                                                            &quot;#FFFFFF&quot;))
                                              -&gt;next()?&gt;&quot;&gt;
  &lt;td&gt;&lt;?php echo $this-&gt;escape($book[&#039;author&#039;]) ?&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;?php endforeach;?&gt;

// Moving in backwards order and assign function
$this-&gt;cycle()-&gt;assign(array(&quot;#F0F0F0&quot;,&quot;#FFFFFF&quot;));
$this-&gt;cycle()-&gt;prev();
?&gt;
</pre>


        <div class="example-contents"><p>
            The output
        </p></div>

        <pre class="programlisting brush: php">
&lt;tr style=&quot;background-color:&#039;#F0F0F0&#039;&quot;&gt;
   &lt;td&gt;First&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color:&#039;#FFFFFF&#039;&quot;&gt;
   &lt;td&gt;Second&lt;/td&gt;
&lt;/tr&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.cycle.advanceusage"><div class="info"><p><b>Example #7 Working with two or more cycles</b></p></div>
        

       <div class="example-contents"><p>
           To use two cycles you have to specify the names of cycles. Just set second parameter in
           cycle method. <strong class="command">$this-&gt;cycle(array(&quot;#F0F0F0&quot;,&quot;#FFFFFF&quot;),&#039;cycle2&#039;)</strong>. You
           can also use setName($name) function.
        </p></div>
    </div>

    <pre class="programlisting brush: php">
&lt;?php foreach ($this-&gt;books as $book):?&gt;
  &lt;tr style=&quot;background-color:&lt;?php echo $this-&gt;cycle(array(&quot;#F0F0F0&quot;,
                                                            &quot;#FFFFFF&quot;))
                                              -&gt;next()?&gt;&quot;&gt;
  &lt;td&gt;&lt;?php echo $this-&gt;cycle(array(1,2,3),&#039;number&#039;)-&gt;next()?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $this-&gt;escape($book[&#039;author&#039;])?&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;?php endforeach;?&gt;
</pre>

</div>
        <div class="section" id="zend.view.helpers.initial.partial"><div class="info"><h1 class="title">Partial Helper</h1></div>
    

    <p class="para">
        The <span class="classname">Partial</span> view helper is used to render a specified
        template within its own variable scope. The primary use is for reusable
        template fragments with which you do not need to worry about variable
        name clashes. Additionally, they allow you to specify partial view
        scripts from specific modules.
    </p>

    <p class="para">
        A sibling to the <span class="classname">Partial</span>, the <span class="classname">PartialLoop</span> view
        helper allows you to pass iterable data, and render a partial for each
        item.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>PartialLoop Counter</b><br /></span>
        

        <p class="para">
            The <span class="classname">PartialLoop</span> view helper assigns a variable to the view named
            <em class="emphasis">partialCounter</em> which passes the current position of the array to
            the view script. This provides an easy way to have alternating colors on table rows for
            example.
        </p>
    </p></blockquote>

    <div class="example" id="zend.view.helpers.initial.partial.usage"><div class="info"><p><b>Example #8 Basic Usage of Partials</b></p></div>
        

        <div class="example-contents"><p>
            Basic usage of partials is to render a template fragment in its own
            view scope. Consider the following partial script:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php // partial.phtml ?&gt;
&lt;ul&gt;
    &lt;li&gt;From: &lt;?php echo $this-&gt;escape($this-&gt;from) ?&gt;&lt;/li&gt;
    &lt;li&gt;Subject: &lt;?php echo $this-&gt;escape($this-&gt;subject) ?&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>


        <div class="example-contents"><p>
            You would then call it from your view script using the following:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;partial(&#039;partial.phtml&#039;, array(
    &#039;from&#039; =&gt; &#039;Team Framework&#039;,
    &#039;subject&#039; =&gt; &#039;view partials&#039;)); ?&gt;
</pre>


        <div class="example-contents"><p>
            Which would then render:
        </p></div>

        <pre class="programlisting brush: html">
&lt;ul&gt;
    &lt;li&gt;From: Team Framework&lt;/li&gt;
    &lt;li&gt;Subject: view partials&lt;/li&gt;
&lt;/ul&gt;
</pre>

    </div>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>What is a model?</b><br /></span>
        

        <p class="para">
            A model used with the <span class="classname">Partial</span> view helper can be
            one of the following:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Array</em>. If an array is passed, it
                    should be associative, as its key/value pairs are
                    assigned to the view with keys as view variables.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Object implementing toArray() method</em>. If an object is
                    passed an has a  <span class="methodname">toArray()</span> method, the results of
                     <span class="methodname">toArray()</span> will be assigned to the view
                    object as view variables.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Standard object</em>. Any other object
                    will assign the results of
                     <span class="methodname">object_get_vars()</span> (essentially all public
                    properties of the object) to the view object.
                </p>
            </li>
        </ul>

        <p class="para">
            If your model is an object, you may want to have it passed
            <em class="emphasis">as an object</em> to the partial script, instead
            of serializing it to an array of variables. You can do this by
            setting the &#039;objectKey&#039; property of the appropriate helper:
        </p>

        <pre class="programlisting brush: php">
// Tell partial to pass objects as &#039;model&#039; variable
$view-&gt;partial()-&gt;setObjectKey(&#039;model&#039;);

// Tell partial to pass objects from partialLoop as &#039;model&#039; variable
// in final partial view script:
$view-&gt;partialLoop()-&gt;setObjectKey(&#039;model&#039;);
</pre>


        <p class="para">
            This technique is particularly useful when passing
            <span class="classname">Zend_Db_Table_Rowset</span>s to
             <span class="methodname">partialLoop()</span>, as you then have full access to your
            row objects within the view scripts, allowing you to call
            methods on them (such as retrieving values from parent or
            dependent rows).
        </p>
    </p></blockquote>

    <div class="example" id="zend.view.helpers.initial.partial.partialloop"><div class="info"><p><b>Example #9 Using PartialLoop to Render Iterable Models</b></p></div>
        

        <div class="example-contents"><p>
            Typically, you&#039;ll want to use partials in a loop, to render the same
            content fragment many times; this way you can put large blocks of
            repeated content or complex display logic into a single location.
            However this has a performance impact, as the partial helper needs
            to be invoked once for each iteration.
        </p></div>

        <div class="example-contents"><p>
            The <span class="classname">PartialLoop</span> view helper helps solve this issue. It
            allows you to pass an iterable item (array or object implementing
            <em class="emphasis">Iterator</em>) as the model. It then iterates over this,
            passing, the items to the partial script as the model. Items in the
            iterator may be any model the <span class="classname">Partial</span> view helper
            allows.
        </p></div>

        <div class="example-contents"><p>
            Let&#039;s assume the following partial view script:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php // partialLoop.phtml ?&gt;
    &lt;dt&gt;&lt;?php echo $this-&gt;key ?&gt;&lt;/dt&gt;
    &lt;dd&gt;&lt;?php echo $this-&gt;value ?&gt;&lt;/dd&gt;
</pre>


        <div class="example-contents"><p>
            And the following &quot;model&quot;:
        </p></div>

        <pre class="programlisting brush: php">
$model = array(
    array(&#039;key&#039; =&gt; &#039;Mammal&#039;, &#039;value&#039; =&gt; &#039;Camel&#039;),
    array(&#039;key&#039; =&gt; &#039;Bird&#039;, &#039;value&#039; =&gt; &#039;Penguin&#039;),
    array(&#039;key&#039; =&gt; &#039;Reptile&#039;, &#039;value&#039; =&gt; &#039;Asp&#039;),
    array(&#039;key&#039; =&gt; &#039;Fish&#039;, &#039;value&#039; =&gt; &#039;Flounder&#039;),
);
</pre>


        <div class="example-contents"><p>
            In your view script, you could then invoke the
            <span class="classname">PartialLoop</span> helper:
        </p></div>

        <pre class="programlisting brush: php">
&lt;dl&gt;
&lt;?php echo $this-&gt;partialLoop(&#039;partialLoop.phtml&#039;, $model) ?&gt;
&lt;/dl&gt;
</pre>


        <pre class="programlisting brush: html">
&lt;dl&gt;
    &lt;dt&gt;Mammal&lt;/dt&gt;
    &lt;dd&gt;Camel&lt;/dd&gt;

    &lt;dt&gt;Bird&lt;/dt&gt;
    &lt;dd&gt;Penguin&lt;/dd&gt;

    &lt;dt&gt;Reptile&lt;/dt&gt;
    &lt;dd&gt;Asp&lt;/dd&gt;

    &lt;dt&gt;Fish&lt;/dt&gt;
    &lt;dd&gt;Flounder&lt;/dd&gt;
&lt;/dl&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.partial.modules"><div class="info"><p><b>Example #10 Rendering Partials in Other Modules</b></p></div>
        

        <div class="example-contents"><p>
            Sometime a partial will exist in a different module. If you know the
            name of the module, you can pass it as the second argument to either
             <span class="methodname">partial()</span> or  <span class="methodname">partialLoop()</span>, moving the
            <var class="varname">$model</var> argument to third position.
        </p></div>

        <div class="example-contents"><p>
            For instance, if there&#039;s a pager partial you wish to use that&#039;s in
            the &#039;list&#039; module, you could grab it as follows:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;partial(&#039;pager.phtml&#039;, &#039;list&#039;, $pagerData) ?&gt;
</pre>


        <div class="example-contents"><p>
            In this way, you can re-use partials created specifically for other
            modules. That said, it&#039;s likely a better practice to put re-usable
            partials in shared view script paths.
        </p></div>
    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.placeholder"><div class="info"><h1 class="title">Placeholder Helper</h1></div>
    

    <p class="para">
        The <span class="classname">Placeholder</span> view helper is used to persist content
        between view scripts and view instances. It also offers some useful
        features such as aggregating content, capturing view script content
        for later use, and adding pre- and post-text to content (and custom
        separators for aggregated content).
    </p>

    <div class="example" id="zend.view.helpers.initial.placeholder.usage"><div class="info"><p><b>Example #11 Basic Usage of Placeholders</b></p></div>
        

        <div class="example-contents"><p>
            Basic usage of placeholders is to persist view data. Each invocation
            of the <span class="classname">Placeholder</span> helper expects a placeholder name;
            the helper then returns a placeholder container object that you can
            either manipulate or simply echo out.
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php $this-&gt;placeholder(&#039;foo&#039;)-&gt;set(&quot;Some text for later&quot;) ?&gt;

&lt;?php
    echo $this-&gt;placeholder(&#039;foo&#039;);
    // outputs &quot;Some text for later&quot;
?&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.placeholder.aggregation"><div class="info"><p><b>Example #12 Using Placeholders to Aggregate Content</b></p></div>
        

        <div class="example-contents"><p>
            Aggregating content via placeholders can be useful at times as well.
            For instance, your view script may have a variable array from which
            you wish to retrieve messages to display later; a later view script
            can then determine how those will be rendered.
        </p></div>

        <div class="example-contents"><p>
            The <span class="classname">Placeholder</span> view helper uses containers that extend
            <span class="classname">ArrayObject</span>, providing a rich featureset for
            manipulating arrays. In addition, it offers a variety of methods for
            formatting the content stored in the container:
        </p></div>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                     <span class="methodname">setPrefix($prefix)</span> sets text with which to
                    prefix the content. Use  <span class="methodname">getPrefix()</span> at any time
                    to determine what the current setting is.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">setPostfix($prefix)</span> sets text with which to
                    append the content. Use  <span class="methodname">getPostfix()</span> at any time
                    to determine what the current setting is.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">setSeparator($prefix)</span> sets text with which to
                    separate aggregated content. Use  <span class="methodname">getSeparator()</span>
                    at any time to determine what the current setting is.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">setIndent($prefix)</span> can be used to set an
                    indentation value for content. If an integer is passed,
                    that number of spaces will be used; if a string is passed,
                    the string will be used. Use  <span class="methodname">getIndent()</span>
                    at any time to determine what the current setting is.
                </p>
            </li>
        </ul>

        <pre class="programlisting brush: php">
&lt;!-- first view script --&gt;
&lt;?php $this-&gt;placeholder(&#039;foo&#039;)-&gt;exchangeArray($this-&gt;data) ?&gt;
</pre>


        <pre class="programlisting brush: php">
&lt;!-- later view script --&gt;
&lt;?php
$this-&gt;placeholder(&#039;foo&#039;)-&gt;setPrefix(&quot;&lt;ul&gt;\n    &lt;li&gt;&quot;)
                         -&gt;setSeparator(&quot;&lt;/li&gt;&lt;li&gt;\n&quot;)
                         -&gt;setIndent(4)
                         -&gt;setPostfix(&quot;&lt;/li&gt;&lt;/ul&gt;\n&quot;);
?&gt;

&lt;?php
    echo $this-&gt;placeholder(&#039;foo&#039;);
    // outputs as unordered list with pretty indentation
?&gt;
</pre>


        <div class="example-contents"><p>
            Because the <span class="classname">Placeholder</span> container objects extend
            <span class="classname">ArrayObject</span>, you can also assign content to a specific
            key in the container easily, instead of simply pushing it into the
            container. Keys may be accessed either as object properties or as
            array keys.
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php $this-&gt;placeholder(&#039;foo&#039;)-&gt;bar = $this-&gt;data ?&gt;
&lt;?php echo $this-&gt;placeholder(&#039;foo&#039;)-&gt;bar ?&gt;

&lt;?php
$foo = $this-&gt;placeholder(&#039;foo&#039;);
echo $foo[&#039;bar&#039;];
?&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.placeholder.capture"><div class="info"><p><b>Example #13 Using Placeholders to Capture Content</b></p></div>
        

        <div class="example-contents"><p>
            Occasionally you may have content for a placeholder in a view script
            that is easiest to template; the <span class="classname">Placeholder</span> view
            helper allows you to capture arbitrary content for later rendering
            using the following <acronym class="acronym">API</acronym>.
        </p></div>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                     <span class="methodname">captureStart($type, $key)</span> begins capturing
                    content.
                </p>

                <p class="para">
                    <var class="varname">$type</var> should be one of the
                    <span class="classname">Placeholder</span> constants <b><tt>APPEND</tt></b> or
                    <b><tt>SET</tt></b>. If <b><tt>APPEND</tt></b>, captured content
                    is appended to the list of current content in the
                    placeholder; if <b><tt>SET</tt></b>, captured content is used
                    as the sole value of the placeholder (potentially replacing
                    any previous content). By default, <var class="varname">$type</var> is
                    <b><tt>APPEND</tt></b>.
                </p>

                <p class="para">
                    <var class="varname">$key</var> can be used to specify a specific key in
                    the placeholder container to which you want content
                    captured.
                </p>

                <p class="para">
                     <span class="methodname">captureStart()</span> locks capturing until
                     <span class="methodname">captureEnd()</span> is called; you cannot nest
                    capturing with the same placeholder container. Doing so will
                    raise an exception.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">captureEnd()</span> stops capturing content, and
                    places it in the container object according to how
                     <span class="methodname">captureStart()</span> was called.
                </p>
            </li>
        </ul>

        <pre class="programlisting brush: php">
&lt;!-- Default capture: append --&gt;
&lt;?php $this-&gt;placeholder(&#039;foo&#039;)-&gt;captureStart();
foreach ($this-&gt;data as $datum): ?&gt;
&lt;div class=&quot;foo&quot;&gt;
    &lt;h2&gt;&lt;?php echo $datum-&gt;title ?&gt;&lt;/h2&gt;
    &lt;p&gt;&lt;?php echo $datum-&gt;content ?&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;?php endforeach; ?&gt;
&lt;?php $this-&gt;placeholder(&#039;foo&#039;)-&gt;captureEnd() ?&gt;

&lt;?php echo $this-&gt;placeholder(&#039;foo&#039;) ?&gt;
</pre>


        <pre class="programlisting brush: php">
&lt;!-- Capture to key --&gt;
&lt;?php $this-&gt;placeholder(&#039;foo&#039;)-&gt;captureStart(&#039;SET&#039;, &#039;data&#039;);
foreach ($this-&gt;data as $datum): ?&gt;
&lt;div class=&quot;foo&quot;&gt;
    &lt;h2&gt;&lt;?php echo $datum-&gt;title ?&gt;&lt;/h2&gt;
    &lt;p&gt;&lt;?php echo $datum-&gt;content ?&gt;&lt;/p&gt;
&lt;/div&gt;
 &lt;?php endforeach; ?&gt;
&lt;?php $this-&gt;placeholder(&#039;foo&#039;)-&gt;captureEnd() ?&gt;

&lt;?php echo $this-&gt;placeholder(&#039;foo&#039;)-&gt;data ?&gt;
</pre>

    </div>

    <div class="section" id="zend.view.helpers.initial.placeholder.implementations"><div class="info"><h1 class="title">Concrete Placeholder Implementations</h1></div>
        

        <p class="para">
            Zend Framework ships with a number of &quot;concrete&quot; placeholder
            implementations. These are for commonly used placeholders: doctype,
            page title, and various &lt;head&gt; elements. In all cases, calling
            the placeholder with no arguments returns the element itself.
        </p>

        <p class="para">
            Documentation for each element is covered separately, as linked
            below:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <a href="zend.view.helpers.html#zend.view.helpers.initial.doctype" class="link">Doctype</a>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.view.helpers.html#zend.view.helpers.initial.headlink" class="link">HeadLink</a>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.view.helpers.html#zend.view.helpers.initial.headmeta" class="link">HeadMeta</a>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.view.helpers.html#zend.view.helpers.initial.headscript" class="link">HeadScript</a>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.view.helpers.html#zend.view.helpers.initial.headstyle" class="link">HeadStyle</a>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.view.helpers.html#zend.view.helpers.initial.headtitle" class="link">HeadTitle</a>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.view.helpers.html#zend.view.helpers.initial.inlinescript" class="link">InlineScript</a>
                </p>
            </li>
        </ul>
    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.doctype"><div class="info"><h1 class="title">Doctype Helper</h1></div>
    

    <p class="para">
        Valid <acronym class="acronym">HTML</acronym> and <acronym class="acronym">XHTML</acronym> documents should include a
        <b><tt>DOCTYPE</tt></b> declaration. Besides being difficult to remember, these can
        also affect how certain elements in your document should be rendered (for instance,
        CDATA escaping in <em class="emphasis">&lt;script&gt;</em> and
        <em class="emphasis">&lt;style&gt;</em> elements.
    </p>

    <p class="para">
        The <span class="classname">Doctype</span> helper allows you to specify one of the
        following types:
    </p>

    <ul class="itemizedlist">
        <li class="listitem"><p class="para"><b><tt>XHTML11</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>XHTML1_STRICT</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>XHTML1_TRANSITIONAL</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>XHTML1_FRAMESET</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>XHTML1_RDFA</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>XHTML_BASIC1</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>HTML4_STRICT</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>HTML4_LOOSE</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>HTML4_FRAMESET</tt></b></p></li>
        <li class="listitem"><p class="para"><b><tt>HTML5</tt></b></p></li>
    </ul>

    <p class="para">
        You can also specify a custom doctype as long as it is well-formed.
    </p>

    <p class="para">
        The <span class="classname">Doctype</span> helper is a concrete implementation of the
        <a href="zend.view.helpers.html#zend.view.helpers.initial.placeholder" class="link">Placeholder helper</a>.
    </p>

    <div class="example" id="zend.view.helpers.initial.doctype.basicusage"><div class="info"><p><b>Example #14 Doctype Helper Basic Usage</b></p></div>
        

        <div class="example-contents"><p>
            You may specify the doctype at any time. However, helpers that
            depend on the doctype for their output will recognize it only after
            you have set it, so the easiest approach is to specify it in your
            bootstrap:
        </p></div>

        <pre class="programlisting brush: php">
$doctypeHelper = new Zend_View_Helper_Doctype();
$doctypeHelper-&gt;doctype(&#039;XHTML1_STRICT&#039;);
</pre>


        <div class="example-contents"><p>
            And then print it out on top of your layout script:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;doctype() ?&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.doctype.retrieving"><div class="info"><p><b>Example #15 Retrieving the Doctype</b></p></div>
        

        <div class="example-contents"><p>
            If you need to know the doctype, you can do so by calling
             <span class="methodname">getDoctype()</span> on the object, which is returned by
            invoking the helper.
        </p></div>

        <pre class="programlisting brush: php">
$doctype = $view-&gt;doctype()-&gt;getDoctype();
</pre>


        <div class="example-contents"><p>
            Typically, you&#039;ll simply want to know if the doctype is <acronym class="acronym">XHTML</acronym> or
            not; for this, the  <span class="methodname">isXhtml()</span> method will suffice:
        </p></div>

        <pre class="programlisting brush: php">
if ($view-&gt;doctype()-&gt;isXhtml()) {
    // do something differently
}
</pre>


        <div class="example-contents"><p>
            You can also check if the doctype represents an <acronym class="acronym">HTML5</acronym> document.
        </p></div>

        <pre class="programlisting brush: php">
if ($view-&gt;doctype()-&gt;isHtml5()) {
    // do something differently
}
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.doctype.xhtml1_rdfa"><div class="info"><p><b>Example #16 Choosing a Doctype to Use with the Open Graph Protocol</b></p></div>
        

        <div class="example-contents"><p>
            To implement the <a href="http://opengraphprotocol.org/" class="link external">&raquo; 
            Open Graph Protocol</a>, you may specify the XHTML1_RDFA doctype.
            This doctype allows a developer to use the <a href="http://www.w3.org/TR/xhtml-rdfa-primer/" class="link external">&raquo; 
            Resource Description Framework</a> within an <acronym class="acronym">XHTML</acronym> document.
        </p></div>

        <pre class="programlisting brush: php">
$doctypeHelper = new Zend_View_Helper_Doctype();
$doctypeHelper-&gt;doctype(&#039;XHTML1_RDFA&#039;);
</pre>


        <div class="example-contents"><p>
        The RDFa doctype allows XHTML to validate when the &#039;property&#039;
        meta tag attribute is used per the Open Graph Protocol spec.  Example
        within a view script:
        </p></div>

        <pre class="programlisting brush: html">
&lt;?php echo $this-&gt;doctype(&#039;XHTML1_RDFA&#039;); ?&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:og=&quot;http://opengraphprotocol.org/schema/&quot;&gt;
&lt;head&gt;
   &lt;meta property=&quot;og:type&quot; content=&quot;musician&quot; /&gt;
</pre>


        <div class="example-contents"><p>
            In the previous example, we set the property to og:type. The og references
            the Open Graph namespace we specified in the html tag.
            The content identifies the page as being about a musician.  See
            the <a href="http://opengraphprotocol.org/" class="link external">&raquo; Open Graph Protocol documentation</a>
            for supported properties. The <a href="zend.view.helpers.html#zend.view.helpers.initial.headmeta" class="link">HeadMeta helper</a>
            may be used to programmatically set these Open Graph Protocol meta tags.
        </p></div>

        <div class="example-contents"><p>
            Here is how you check if the doctype is set to XHTML1_RDFA:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;doctype() ?&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; 
      &lt;?php if ($view-&gt;doctype()-&gt;isRdfa()): ?&gt;
      xmlns:og=&quot;http://opengraphprotocol.org/schema/&quot;
      xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;
      &lt;?php endif; ?&gt;
&gt;
</pre>

        
    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.gravatar"><div class="info"><h1 class="title">Gravatar View Helper</h1></div>
    

    <p class="para">
        The <span class="classname">Gravatar</span> view helper is used to received avatars from Gravatar&#039;s
        service.
    </p>

    <div class="example" id="zend.view.helpers.initial.gravatar.usage"><div class="info"><p><b>Example #17 Basic Usage of Gravatar View Helper</b></p></div>
        

        <pre class="programlisting brush: php">
// From a view script (using XHTML DOCTYPE):
echo $this-&gt;gravatar(&#039;example@example.com&#039;);

/* results in the following output:
    &lt;img src=&quot;http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=80&amp;d=mm&amp;r=g&quot; /&gt;
 */
</pre>

    </div>

    <blockquote class="note"><p><b class="note">Note</b>: 
        <p class="para">
            Of course we can configure this helper. We can change height of image (by default it is
            80px), and add <acronym class="acronym">CSS</acronym> class or other attributes to image tag. The above
            simply shows the most basic usage.
        </p>
    </p></blockquote>

    <div class="warning"><b class="warning">Warning</b><div class="info"><h1 class="title">Use a valid email address!</h1></div>
        

        <p class="para">
            The email address you provide the helper should be valid. This class does not validate
            the address (only the rating parameter). It is recommended to validate your email
            address within your model layer.
        </p>
    </div>

    <div class="example" id="zend.view.helpers.initial.gravatar.advanced"><div class="info"><p><b>Example #18 Advanced Usage of Gravatar View Helper</b></p></div>
        

        <div class="example-contents"><p>
            There are several ways to configure the returned gravatar. In most cases, you may either
            pass an array of options as a second argument to the helper, or call methods on the
            returned object in order to configure it.
        </p></div>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    The <var class="varname">img_size</var> option can be used to specify an alternate
                    height; alternately, call  <span class="methodname">setImgSize()</span>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The <var class="varname">secure</var> option can be used to force usage of SSL in
                    the returned image URI by passing a boolean <b><tt>true</tt></b> value (or
                    disabling SSL usage by passing <b><tt>false</tt></b>). Alternately, call
                    the  <span class="methodname">setSecure()</span> method. (By default, the setting
                    follows the same security as the current page request.)
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    To add attributes to the image, pass an array of key/value pairs as the
                    <em class="emphasis">third</em> argument to the helper, or call the
                     <span class="methodname">setAttribs()</span> method.
                </p>
            </li>
        </ul>

        <pre class="programlisting brush: php">
// Within the view script (using HTML DOCTYPE)
echo $this-&gt;gravatar(&#039;example@example.com&#039;,
    array(&#039;imgSize&#039; =&gt; 90, &#039;defaultImg&#039; =&gt; &#039;monsterid&#039;, &#039;secure&#039; =&gt; true),
    array(&#039;class&#039; =&gt; &#039;avatar&#039;, &#039;title&#039; =&gt; &#039;Title for this image&#039;)
);
    
// Or use mutator methods
$this-&gt;gravatar()
     -&gt;setEmail(&#039;example@example.com&#039;)
     -&gt;setImgSize(90)
     -&gt;setDefaultImg(Zend_View_Helper_Gravatar::DEFAULT_MONSTERID)
     -&gt;setSecure(true)
     -&gt;setAttribs(array(&#039;class&#039; =&gt; &#039;avatar&#039;, &#039;title&#039; =&gt; &#039;Title for this image&#039;));

/* Both generate the following output:
&lt;img class=&quot;avatar&quot; title=&quot;Title for this image&quot;
    src=&quot;https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=90&amp;d=monsterid&amp;r=g&quot; &gt;
 */
</pre>

    </div>

    <div class="section" id="zend.view.helper.gravatar.options"><div class="info"><h1 class="title">Options</h1></div>
        

        <dl>
<div class="info"><h1 class="title">Zend_Service_Gravatar Options</h1></div>
            

            <dt>

                <dt class="term">img_size</dt>

                <dd>

                    <p class="para">
                        An integer describing the height of the avatar, in pixels; defaults to &quot;80&quot;.
                    </p>
                </dd>

            </dt>


            <dt>

                <dt class="term">default_img</dt>

                <dd>

                    <p class="para">
                        Image to return if the gravatar service is unable to match the email address
                        provided. Defaults to &quot;mm&quot;, the &quot;mystery man&quot; image.
                    </p>
                </dd>

            </dt>


            <dt>

                <dt class="term">rating</dt>

                <dd>

                    <p class="para">
                        Audience rating to confine returned images to. Defaults to &quot;g&quot;; may be one
                        of &quot;g&quot;, &quot;pg&quot;, &quot;r&quot;, or &quot;x&quot;, in order of least offensive to most offensive.
                    </p>
                </dd>

            </dt>


            <dt>

                <dt class="term">secure</dt>

                <dd>

                    <p class="para">
                        Whether or not to load the image via an SSL connection. Defaults to the what
                        is detected from the current request.
                    </p>
                </dd>

            </dt>

        </dl>

    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.headlink"><div class="info"><h1 class="title">HeadLink Helper</h1></div>
    

    <p class="para">
        The <acronym class="acronym">HTML</acronym> <em class="emphasis">&lt;link&gt;</em> element is increasingly used
        for linking a variety of resources for your site: stylesheets, feeds,
        favicons, trackbacks, and more. The <span class="classname">HeadLink</span> helper
        provides a simple interface for creating and aggregating these elements
        for later retrieval and output in your layout script.
    </p>

    <p class="para">
        The <span class="classname">HeadLink</span> helper has special methods for adding
        stylesheet links to its stack:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                <strong class="command">appendStylesheet($href, $media, $conditionalStylesheet, $extras)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetStylesheet($index, $href, $media, $conditionalStylesheet,
                    $extras)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependStylesheet($href, $media, $conditionalStylesheet, $extras)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setStylesheet($href, $media, $conditionalStylesheet, $extras)</strong>
            </p>
        </li>
    </ul>

    <p class="para">
        The <var class="varname">$media</var> value defaults to &#039;screen&#039;, but may be any valid
        media value. <var class="varname">$conditionalStylesheet</var> is a string or boolean
        <b><tt>FALSE</tt></b>, and will be used at rendering time to determine if special
        comments should be included to prevent loading of the stylesheet on certain platforms.
        <var class="varname">$extras</var> is an array of any extra values that you want to be added
        to the tag.
    </p>

    <p class="para">
        Additionally, the <span class="classname">HeadLink</span> helper has special methods for
        adding &#039;alternate&#039; links to its stack:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                <strong class="command">appendAlternate($href, $type, $title, $extras)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetAlternate($index, $href, $type, $title, $extras)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependAlternate($href, $type, $title, $extras)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setAlternate($href, $type, $title, $extras)</strong>
            </p>
        </li>
    </ul>

    <p class="para">
        The  <span class="methodname">headLink()</span> helper method allows specifying all
        attributes necessary for a <em class="emphasis">&lt;link&gt;</em> element, and allows
        you to also specify placement -- whether the new element replaces all
        others, prepends (top of stack), or appends (end of stack).
    </p>

    <p class="para">
        The <span class="classname">HeadLink</span> helper is a concrete implementation of the
        <a href="zend.view.helpers.html#zend.view.helpers.initial.placeholder" class="link">Placeholder
            helper</a>.
    </p>

    <div class="example" id="zend.view.helpers.initial.headlink.basicusage"><div class="info"><p><b>Example #19 HeadLink Helper Basic Usage</b></p></div>
        

        <div class="example-contents"><p>
            You may specify a <em class="emphasis">headLink</em> at any time. Typically, you
            will specify global links in your layout script, and application
            specific links in your application view scripts. In your layout
            script, in the &lt;head&gt; section, you will then echo the helper
            to output it.
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php // setting links in a view script:
$this-&gt;headLink()-&gt;appendStylesheet(&#039;/styles/basic.css&#039;)
                 -&gt;headLink(array(&#039;rel&#039; =&gt; &#039;favicon&#039;,
                                  &#039;href&#039; =&gt; &#039;/img/favicon.ico&#039;),
                                  &#039;PREPEND&#039;)
                 -&gt;prependStylesheet(&#039;/styles/moz.css&#039;,
                                     &#039;screen&#039;,
                                     true,
                                     array(&#039;id&#039; =&gt; &#039;my_stylesheet&#039;));
?&gt;
&lt;?php // rendering the links: ?&gt;
&lt;?php echo $this-&gt;headLink() ?&gt;
</pre>

    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.headmeta"><div class="info"><h1 class="title">HeadMeta Helper</h1></div>
    

    <p class="para">
        The <acronym class="acronym">HTML</acronym> <em class="emphasis">&lt;meta&gt;</em> element is used to provide
        meta information about your <acronym class="acronym">HTML</acronym> document -- typically keywords, document
        character set, caching pragmas, etc. Meta tags may be either of the
        &#039;http-equiv&#039; or &#039;name&#039; types, must contain a &#039;content&#039; attribute, and
        can also have either of the &#039;lang&#039; or &#039;scheme&#039; modifier attributes.
    </p>

    <p class="para">
        The <span class="classname">HeadMeta</span> helper supports the following methods for
        setting and adding meta tags:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                <strong class="command">appendName($keyValue, $content, $conditionalName)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetName($index, $keyValue, $content, $conditionalName)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependName($keyValue, $content, $conditionalName)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setName($keyValue, $content, $modifiers)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">appendHttpEquiv($keyValue, $content, $conditionalHttpEquiv)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetHttpEquiv($index, $keyValue, $content,
                    $conditionalHttpEquiv)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependHttpEquiv($keyValue, $content, $conditionalHttpEquiv)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setHttpEquiv($keyValue, $content, $modifiers)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setCharset($charset)</strong>
            </p>
        </li>
    </ul>

    <p class="para">
        The following methods are also supported with XHTML1_RDFA doctype
        set with the <a href="zend.view.helpers.html#zend.view.helpers.initial.doctype" class="link">Doctype helper</a>:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                <strong class="command">appendProperty($property, $content, $modifiers)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetProperty($index, $property, $content, $modifiers)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependProperty($property, $content, $modifiers)</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setProperty($property, $content, $modifiers)</strong>
            </p>
        </li>
    </ul>

    <p class="para">
        The <var class="varname">$keyValue</var> item is used to define a value for the &#039;name&#039;
        or &#039;http-equiv&#039; key; <var class="varname">$content</var> is the value for the
        &#039;content&#039; key, and <var class="varname">$modifiers</var> is an optional associative
        array that can contain keys for &#039;lang&#039; and/or &#039;scheme&#039;.
    </p>

    <p class="para">
        You may also set meta tags using the  <span class="methodname">headMeta()</span> helper
        method, which has the following signature: <strong class="command">headMeta($content,
            $keyValue, $keyType = &#039;name&#039;, $modifiers = array(), $placement =
            &#039;APPEND&#039;)</strong>. <var class="varname">$keyValue</var> is the content for the key
        specified in <var class="varname">$keyType</var>, which should be either &#039;name&#039; or
        &#039;http-equiv&#039;. <var class="varname">$keyType</var> may also be specified as &#039;property&#039; if the
        doctype has been set to XHTML1_RDFA. <var class="varname">$placement</var> can be &#039;SET&#039; (overwrites
        all previously stored values), &#039;APPEND&#039; (added to end of stack), or
        &#039;PREPEND&#039; (added to top of stack).
    </p>

    <p class="para">
        <span class="classname">HeadMeta</span> overrides each of  <span class="methodname">append()</span>,
         <span class="methodname">offsetSet()</span>,  <span class="methodname">prepend()</span>, and
         <span class="methodname">set()</span> to enforce usage of the special methods as listed above.
        Internally, it stores each item as a <span class="property">stdClass</span> token, which it later
        serializes using the  <span class="methodname">itemToString()</span> method. This allows you
        to perform checks on the items in the stack, and optionally modify these
        items by simply modifying the object returned.
    </p>

    <p class="para">
        The <span class="classname">HeadMeta</span> helper is a concrete implementation of the
        <a href="zend.view.helpers.html#zend.view.helpers.initial.placeholder" class="link">Placeholder helper</a>.
    </p>

    <div class="example" id="zend.view.helpers.initial.headmeta.basicusage"><div class="info"><p><b>Example #20 HeadMeta Helper Basic Usage</b></p></div>
        

        <div class="example-contents"><p>
            You may specify a new meta tag at any time. Typically, you
            will specify client-side caching rules or SEO keywords.
        </p></div>

        <div class="example-contents"><p>
            For instance, if you wish to specify SEO keywords, you&#039;d be creating
            a meta name tag with the name &#039;keywords&#039; and the content the
            keywords you wish to associate with your page:
        </p></div>

        <pre class="programlisting brush: php">
// setting meta keywords
$this-&gt;headMeta()-&gt;appendName(&#039;keywords&#039;, &#039;framework, PHP, productivity&#039;);
</pre>


        <div class="example-contents"><p>
            If you wished to set some client-side caching rules, you&#039;d set
            http-equiv tags with the rules you wish to enforce:
        </p></div>

        <pre class="programlisting brush: php">
// disabling client-side cache
$this-&gt;headMeta()-&gt;appendHttpEquiv(&#039;expires&#039;,
                                   &#039;Wed, 26 Feb 1997 08:21:57 GMT&#039;)
                 -&gt;appendHttpEquiv(&#039;pragma&#039;, &#039;no-cache&#039;)
                 -&gt;appendHttpEquiv(&#039;Cache-Control&#039;, &#039;no-cache&#039;);
</pre>


        <div class="example-contents"><p>
            Another popular use for meta tags is setting the content type,
            character set, and language:
        </p></div>

        <pre class="programlisting brush: php">
// setting content type and character set
$this-&gt;headMeta()-&gt;appendHttpEquiv(&#039;Content-Type&#039;,
                                   &#039;text/html; charset=UTF-8&#039;)
                 -&gt;appendHttpEquiv(&#039;Content-Language&#039;, &#039;en-US&#039;);
</pre>


        <div class="example-contents"><p>
            If you are serving an <acronym class="acronym">HTML</acronym>5 document, you should provide the
            character set like this:
        </p></div>

        <pre class="programlisting brush: php">
// setting character set in HTML5
$this-&gt;headMeta()-&gt;setCharset(&#039;UTF-8&#039;); // Will look like &lt;meta charset=&quot;UTF-8&quot;&gt;
</pre>


        <div class="example-contents"><p>
            As a final example, an easy way to display a transitional message
            before a redirect is using a &quot;meta refresh&quot;:
        </p></div>

        <pre class="programlisting brush: php">
// setting a meta refresh for 3 seconds to a new url:
$this-&gt;headMeta()-&gt;appendHttpEquiv(&#039;Refresh&#039;,
                                   &#039;3;URL=http://www.some.org/some.html&#039;);
</pre>


        <div class="example-contents"><p>
            When you&#039;re ready to place your meta tags in the layout, simply echo the helper:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;headMeta() ?&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.headmeta.property"><div class="info"><p><b>Example #21 HeadMeta Usage with XHTML1_RDFA doctype</b></p></div>
        

        <div class="example-contents"><p>
            Enabling the RDFa doctype with the <a href="zend.view.helpers.html#zend.view.helpers.initial.doctype" class="link">Doctype helper</a>
            enables the use of the &#039;property&#039; attribute (in addition to the standard &#039;name&#039; and &#039;http-equiv&#039;) with HeadMeta.
            This is commonly used with the Facebook <a href="http://opengraphprotocol.org/" class="link external">&raquo; Open Graph Protocol</a>.
        </p></div>

        <div class="example-contents"><p>
            For instance, you may specify an open graph page title and type as follows:
        </p></div>

        <pre class="programlisting brush: php">
$this-&gt;doctype(Zend_View_Helper_Doctype::XHTML_RDFA);
$this-&gt;headMeta()-&gt;setProperty(&#039;og:title&#039;, &#039;my article title&#039;);
$this-&gt;headMeta()-&gt;setProperty(&#039;og:type&#039;, &#039;article&#039;);
echo $this-&gt;headMeta();

// output is:
//   &lt;meta property=&quot;og:title&quot; content=&quot;my article title&quot; /&gt;
//   &lt;meta property=&quot;og:type&quot; content=&quot;article&quot; /&gt;
</pre>


    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.headscript"><div class="info"><h1 class="title">HeadScript Helper</h1></div>
    

    <p class="para">
        The <acronym class="acronym">HTML</acronym> <em class="emphasis">&lt;script&gt;</em> element is used to either
        provide inline client-side scripting elements or link to a remote resource
        containing client-side scripting code. The <span class="classname">HeadScript</span>
        helper allows you to manage both.
    </p>

    <p class="para">
        The <span class="classname">HeadScript</span> helper supports the following methods for
        setting and adding scripts:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                <strong class="command">appendFile($src, $type = &#039;text/javascript&#039;, $attrs = array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetFile($index, $src, $type = &#039;text/javascript&#039;, $attrs =
                    array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependFile($src, $type = &#039;text/javascript&#039;, $attrs = array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setFile($src, $type = &#039;text/javascript&#039;, $attrs = array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">appendScript($script, $type = &#039;text/javascript&#039;, $attrs =
                    array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetScript($index, $script, $type = &#039;text/javascript&#039;, $attrs =
                    array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependScript($script, $type = &#039;text/javascript&#039;, $attrs =
                    array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setScript($script, $type = &#039;text/javascript&#039;, $attrs = array())</strong>
            </p>
        </li>
    </ul>

    <p class="para">
        In the case of the * <span class="methodname">File()</span> methods, <var class="varname">$src</var> is
        the remote location of the script to load; this is usually in the form
        of a <acronym class="acronym">URL</acronym> or a path. For the * <span class="methodname">Script()</span> methods,
        <var class="varname">$script</var> is the client-side scripting directives you wish to
        use in the element.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Setting Conditional Comments</b><br /></span>
        

        <p class="para">
            <span class="classname">HeadScript</span> allows you to wrap the script tag in conditional
            comments, which allows you to hide it from specific browsers. To add the conditional
            tags, pass the conditional value as part of the <var class="varname">$attrs</var> parameter in
            the method calls.
        </p>

        <div class="example" id="zend.view.helpers.initial.headscript.conditional"><div class="info"><p><b>Example #22 Headscript With Conditional Comments</b></p></div>
            

            <pre class="programlisting brush: php">
// adding scripts
$this-&gt;headScript()-&gt;appendFile(
    &#039;/js/prototype.js&#039;,
    &#039;text/javascript&#039;,
    array(&#039;conditional&#039; =&gt; &#039;lt IE 7&#039;)
);
</pre>

        </div>
    </p></blockquote>

    <p class="para">
        <span class="classname">HeadScript</span> also allows capturing scripts; this can be
        useful if you want to create the client-side script programmatically,
        and then place it elsewhere. The usage for this will be showed in an
        example below.
    </p>

    <p class="para">
        Finally, you can also use the  <span class="methodname">headScript()</span> method to
        quickly add script elements; the signature for this is
         <span class="methodname">headScript($mode = &#039;FILE&#039;, $spec, $placement = &#039;APPEND&#039;)</span>.
        The <var class="varname">$mode</var> is either &#039;FILE&#039; or &#039;SCRIPT&#039;, depending on if
        you&#039;re linking a script or defining one. <var class="varname">$spec</var> is either
        the script file to link or the script source itself.
        <var class="varname">$placement</var> should be either &#039;APPEND&#039;, &#039;PREPEND&#039;, or &#039;SET&#039;.
    </p>

    <p class="para">
        <span class="classname">HeadScript</span> overrides each of  <span class="methodname">append()</span>,
         <span class="methodname">offsetSet()</span>,  <span class="methodname">prepend()</span>, and
         <span class="methodname">set()</span> to enforce usage of the special methods as listed above.
        Internally, it stores each item as a <span class="property">stdClass</span> token, which it later
        serializes using the  <span class="methodname">itemToString()</span> method. This allows you
        to perform checks on the items in the stack, and optionally modify these
        items by simply modifying the object returned.
    </p>

    <p class="para">
        The <span class="classname">HeadScript</span> helper is a concrete implementation of the
        <a href="zend.view.helpers.html#zend.view.helpers.initial.placeholder" class="link">Placeholder helper</a>.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Use InlineScript for HTML Body Scripts</b><br /></span>
        

        <p class="para">
            <span class="classname">HeadScript</span>&#039;s sibling helper, <a href="zend.view.helpers.html#zend.view.helpers.initial.inlinescript" class="link">InlineScript</a>,
            should be used when you wish to include scripts inline in the <acronym class="acronym">HTML</acronym>
            <em class="emphasis">body</em>. Placing scripts at the end of your document is a
            good practice for speeding up delivery of your page, particularly
            when using 3rd party analytics scripts.
        </p>
    </p></blockquote>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Arbitrary Attributes are Disabled by Default</b><br /></span>
        

        <p class="para">
            By default, <span class="classname">HeadScript</span> only will render
            <em class="emphasis">&lt;script&gt;</em> attributes that are blessed by the W3C.
            These include &#039;type&#039;, &#039;charset&#039;, &#039;defer&#039;, &#039;language&#039;, and &#039;src&#039;.
            However, some javascript frameworks, notably <a href="http://www.dojotoolkit.org/" class="link external">&raquo; Dojo</a>, utilize custom
            attributes in order to modify behavior. To allow such attributes,
            you can enable them via the
             <span class="methodname">setAllowArbitraryAttributes()</span> method:
        </p>

        <pre class="programlisting brush: php">
$this-&gt;headScript()-&gt;setAllowArbitraryAttributes(true);
</pre>

    </p></blockquote>

    <div class="example" id="zend.view.helpers.initial.headscript.basicusage"><div class="info"><p><b>Example #23 HeadScript Helper Basic Usage</b></p></div>
        

        <div class="example-contents"><p>
            You may specify a new script tag at any time. As noted above, these
            may be links to outside resource files or scripts themselves.
        </p></div>

        <pre class="programlisting brush: php">
// adding scripts
$this-&gt;headScript()-&gt;appendFile(&#039;/js/prototype.js&#039;)
                   -&gt;appendScript($onloadScript);
</pre>


        <div class="example-contents"><p>
            Order is often important with client-side scripting; you may need to
            ensure that libraries are loaded in a specific order due to
            dependencies each have; use the various append, prepend, and
            offsetSet directives to aid in this task:
        </p></div>

        <pre class="programlisting brush: php">
// Putting scripts in order

// place at a particular offset to ensure loaded last
$this-&gt;headScript()-&gt;offsetSetFile(100, &#039;/js/myfuncs.js&#039;);

// use scriptaculous effects (append uses next index, 101)
$this-&gt;headScript()-&gt;appendFile(&#039;/js/scriptaculous.js&#039;);

// but always have base prototype script load first:
$this-&gt;headScript()-&gt;prependFile(&#039;/js/prototype.js&#039;);
</pre>


        <div class="example-contents"><p>
            When you&#039;re finally ready to output all scripts in your layout
            script, simply echo the helper:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;headScript() ?&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.headscript.capture"><div class="info"><p><b>Example #24 Capturing Scripts Using the HeadScript Helper</b></p></div>
        

        <div class="example-contents"><p>
            Sometimes you need to generate client-side scripts programmatically.
            While you could use string concatenation, heredocs, and the like,
            often it&#039;s easier just to do so by creating the script and
            sprinkling in <acronym class="acronym">PHP</acronym> tags. <span class="classname">HeadScript</span> lets you do
            just that, capturing it to the stack:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php $this-&gt;headScript()-&gt;captureStart() ?&gt;
var action = &#039;&lt;?php echo $this-&gt;baseUrl ?&gt;&#039;;
$(&#039;foo_form&#039;).action = action;
&lt;?php $this-&gt;headScript()-&gt;captureEnd() ?&gt;
</pre>


        <div class="example-contents"><p>
            The following assumptions are made:
        </p></div>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    The script will be appended to the stack. If you wish for it
                    to replace the stack or be added to the top, you will need
                    to pass &#039;SET&#039; or &#039;PREPEND&#039;, respectively, as the first
                    argument to  <span class="methodname">captureStart()</span>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The script <acronym class="acronym">MIME</acronym> type is assumed to be &#039;text/javascript&#039;; if
                    you wish to specify a different type, you will need to pass it
                    as the second argument to  <span class="methodname">captureStart()</span>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    If you wish to specify any additional attributes for the
                    <em class="emphasis">&lt;script&gt;</em> tag, pass them in an array as
                    the third argument to  <span class="methodname">captureStart()</span>.
                </p>
            </li>
        </ul>
    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.headstyle"><div class="info"><h1 class="title">Assistente HeadStyle</h1></div>
    

    <p class="para">
        O elemento <acronym class="acronym">HTML</acronym> <em class="emphasis">&lt;style&gt;</em> é usado para incluir
        folhas de estilo <acronym class="acronym">CSS</acronym> de forma inline no elemento <acronym class="acronym">HTML</acronym>
        <em class="emphasis">&lt;head&gt;</em>.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Use o HeadLink para &quot;linkar&quot; arquivos CSS</b><br /></span>
        

        <p class="para">
            O <a href="zend.view.helpers.html#zend.view.helpers.initial.headlink" class="link">HeadLink</a> deve ser usado para
            criar elementos <em class="emphasis">&lt;link&gt;</em> para a inclusão de folhas de estilo
            externas. <span class="classname">HeadStyle</span> é usado quando você deseja definir folhas de
            estilo inline.
        </p>
    </p></blockquote>

    <p class="para">
        O assistente <span class="classname">HeadStyle</span> dá suporte aos seguintes métodos para a
        configuração e adição de declarações de folhas de estilo:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                <strong class="command">appendStyle($content, $attributes = array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">offsetSetStyle($index, $content, $attributes = array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">prependStyle($content, $attributes = array())</strong>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <strong class="command">setStyle($content, $attributes = array())</strong>
            </p>
        </li>
    </ul>

    <p class="para">
        Em todos os casos, <var class="varname">$content</var> é a verdadeira declaração
        <acronym class="acronym">CSS</acronym>. <var class="varname">$attributes</var> são quaisquer atributos adicionais
        que você dejesa prover para a tag <span class="property">style</span>: lang, title, media, ou dir são
        todos admissíveis.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Setting Conditional Comments</b><br /></span>
        

        <p class="para">
            <span class="classname">HeadStyle</span> allows you to wrap the style tag in conditional
            comments, which allows you to hide it from specific browsers. To add the conditional
            tags, pass the conditional value as part of the <var class="varname">$attributes</var> parameter
            in the method calls.
        </p>

        <div class="example" id="zend.view.helpers.initial.headstyle.conditional"><div class="info"><p><b>Example #25 Headstyle With Conditional Comments</b></p></div>
            

            <pre class="programlisting brush: php">
// adding scripts
$this-&gt;headStyle()-&gt;appendStyle($styles, array(&#039;conditional&#039; =&gt; &#039;lt IE 7&#039;));
</pre>

        </div>
    </p></blockquote>

    <p class="para">
        <span class="classname">HeadStyle</span> também permite a captura de declarações de estilo; isso
        pode ser útil se você quiser criar as declarações através de programação, e então colocá-las
        em outro lugar. A utilização disso será mostrada em um exemplo abaixo.
    </p>

    <p class="para">
        Finalmente, você pode usar o método  <span class="methodname">headStyle()</span> para acrescentar
        rapidamente elementos de declaração; a assinatura para isso é
         <span class="methodname">headStyle($content$placement = &#039;APPEND&#039;, $attributes = array())</span>.
        <var class="varname">$placement</var> deve ser &#039;APPEND&#039;, &#039;PREPEND&#039;, ou &#039;SET&#039;.
    </p>

    <p class="para">
        <span class="classname">HeadStyle</span> sobrescreve  <span class="methodname">append()</span>,
         <span class="methodname">offsetSet()</span>,  <span class="methodname">prepend()</span>, e
         <span class="methodname">set()</span> para forçar o uso dos métodos especiais listados acima.
        Internamente ele armazena cada item como um token <span class="property">stdClass</span>, que depois
        é serializado usando o método  <span class="methodname">itemToString()</span>. Isso permite que você
        faça verificações nos itens da pilha, e opcionalmente modifique estes itens simplesmente
        modificando o objeto retornado.
    </p>

    <p class="para">
        O assistente <span class="classname">HeadStyle</span> é uma implementação concreta do <a href="zend.view.helpers.html#zend.view.helpers.initial.placeholder" class="link">assistente Placeholder</a>.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>UTF-8 encoding used by default</b><br /></span>
        

        <p class="para">
            By default, Zend Framework uses <acronym class="acronym">UTF-8</acronym> as its default encoding, and,
            specific to this case, <span class="classname">Zend_View</span> does as well. Character encoding
            can be set differently on the view object itself using the
             <span class="methodname">setEncoding()</span> method (or the the <var class="varname">encoding</var>
            instantiation parameter). However, since <span class="classname">Zend_View_Interface</span> does
            not define accessors for encoding, it&#039;s possible that if you are using a custom view
            implementation with this view helper, you will not have a
             <span class="methodname">getEncoding()</span> method, which is what the view helper uses
            internally for determining the character set in which to encode.
        </p>

        <p class="para">
            If you do not want to utilize <acronym class="acronym">UTF-8</acronym> in such a situation, you will
            need to implement a  <span class="methodname">getEncoding()</span> method in your custom view
            implementation.
        </p>
    </p></blockquote>

    <div class="example" id="zend.view.helpers.initial.headstyle.basicusage"><div class="info"><p><b>Example #26 Uso Básico do Assistente HeadStyle</b></p></div>
        

        <div class="example-contents"><p>
            Você pode especificar uma nova tag de estilo a qualquer momento:
        </p></div>

        <pre class="programlisting brush: php">
// adding styles
$this-&gt;headStyle()-&gt;appendStyle($styles);
</pre>


        <div class="example-contents"><p>
            A ordenação é muito importante no <acronym class="acronym">CSS</acronym>; você talvez tenha que
            assegurar que as declarações sejam carregadas em uma ordem específica devido à ordem da
            cascata; use as diretivas append, prepend, e offsetSet para lhe auxiliar nessa tarefa:
        </p></div>

        <pre class="programlisting brush: php">
// Putting styles in order

// place at a particular offset:
$this-&gt;headStyle()-&gt;offsetSetStyle(100, $customStyles);

// place at end:
$this-&gt;headStyle()-&gt;appendStyle($finalStyles);

// place at beginning
$this-&gt;headStyle()-&gt;prependStyle($firstStyles);
</pre>


        <div class="example-contents"><p>
            When you&#039;re finally ready to output all style declarations in your
            layout script, simply echo the helper:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;headStyle() ?&gt;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.headstyle.capture"><div class="info"><p><b>Example #27 Capturing Style Declarations Using the HeadStyle Helper</b></p></div>
        

        <div class="example-contents"><p>
            Sometimes you need to generate <acronym class="acronym">CSS</acronym> style declarations
            programmatically. While you could use string concatenation,
            heredocs, and the like, often it&#039;s easier just to do so by creating
            the styles and sprinkling in <acronym class="acronym">PHP</acronym> tags.
            <span class="classname">HeadStyle</span> lets you do just that, capturing it to the stack:
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php $this-&gt;headStyle()-&gt;captureStart() ?&gt;
body {
    background-color: &lt;?php echo $this-&gt;bgColor ?&gt;;
}
&lt;?php $this-&gt;headStyle()-&gt;captureEnd() ?&gt;
</pre>


        <div class="example-contents"><p>
            The following assumptions are made:
        </p></div>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    The style declarations will be appended to the stack. If you
                    wish for them to replace the stack or be added to the top,
                    you will need to pass &#039;SET&#039; or &#039;PREPEND&#039;, respectively, as
                    the first argument to  <span class="methodname">captureStart()</span>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    If you wish to specify any additional attributes for the
                    <em class="emphasis">&lt;style&gt;</em> tag, pass them in an array as
                    the second argument to  <span class="methodname">captureStart()</span>.
                </p>
            </li>
        </ul>
    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.headtitle"><div class="info"><h1 class="title">HeadTitle Helper</h1></div>
    

    <p class="para">
        The <acronym class="acronym">HTML</acronym> <em class="emphasis">&lt;title&gt;</em> element is used to provide a
        title for an <acronym class="acronym">HTML</acronym> document. The <span class="classname">HeadTitle</span> helper
        allows you to programmatically create and store the title for later retrieval and output.
    </p>

    <p class="para">
        The <span class="classname">HeadTitle</span> helper is a concrete implementation of the
        <a href="zend.view.helpers.html#zend.view.helpers.initial.placeholder" class="link">Placeholder
            helper</a>. It overrides the  <span class="methodname">toString()</span> method to
        enforce generating a <em class="emphasis">&lt;title&gt;</em> element, and adds a
         <span class="methodname">headTitle()</span> method for quick and easy setting and
        aggregation of title elements. The signature for that method is
         <span class="methodname">headTitle($title, $setType = null)</span>; by default, the
        value is appended to the stack (aggregating title segments) if left at null, but you may
        also specify either &#039;PREPEND&#039; (place at top of stack) or &#039;SET&#039;
        (overwrite stack).
    </p>

    <p class="para">
        Since setting the aggregating (attach) order on each call to  <span class="methodname">
        headTitle</span> can be cumbersome, you can set a default attach order
        by calling  <span class="methodname">setDefaultAttachOrder()</span> which is applied
        to all  <span class="methodname">headTitle()</span> calls unless you explicitly
        pass a different attach order as the second parameter.
    </p>

    <div class="example" id="zend.view.helpers.initial.headtitle.basicusage"><div class="info"><p><b>Example #28 HeadTitle Helper Basic Usage</b></p></div>
        

        <div class="example-contents"><p>
            You may specify a title tag at any time. A typical usage would have
            you setting title segments for each level of depth in your
            application: site, controller, action, and potentially resource.
        </p></div>

        <pre class="programlisting brush: php">
 // setting the controller and action name as title segments:
$request = Zend_Controller_Front::getInstance()-&gt;getRequest();
$this-&gt;headTitle($request-&gt;getActionName())
     -&gt;headTitle($request-&gt;getControllerName());

// setting the site in the title; possibly in the layout script:
$this-&gt;headTitle(&#039;Zend Framework&#039;);

// setting a separator string for segments:
$this-&gt;headTitle()-&gt;setSeparator(&#039; / &#039;);
</pre>


        <div class="example-contents"><p>
            When you&#039;re finally ready to render the title in your layout
            script, simply echo the helper:
        </p></div>

        <pre class="programlisting brush: php">
&lt;!-- renders &lt;action&gt; / &lt;controller&gt; / Zend Framework --&gt;
&lt;?php echo $this-&gt;headTitle() ?&gt;
</pre>

    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.object"><div class="info"><h1 class="title">HTML Object Helpers</h1></div>
    

    <p class="para">
        The <acronym class="acronym">HTML</acronym> <em class="emphasis">
&lt;object&gt;</em> element is used for embedding
        media like Flash or QuickTime in web pages. The object view helpers take
        care of embedding media with minimum effort.
    </p>

    <p class="para">
        There are four initial Object helpers:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                 <span class="methodname">htmlFlash()</span>
                Generates markup for embedding Flash files.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">htmlObject()</span>
                Generates markup for embedding a custom Object.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">htmlPage()</span>
                Generates markup for embedding other (X)HTML pages.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">htmlQuicktime()</span>
                Generates markup for embedding QuickTime files.
            </p>
        </li>
    </ul>

    <p class="para">
        All of these helpers share a similar interface. For this reason, this
        documentation will only contain examples of two of these helpers.
    </p>

    <div class="example" id="zend.view.helpers.initial.object.flash"><div class="info"><p><b>Example #29 Flash helper</b></p></div>
        

        <div class="example-contents"><p>
            Embedding Flash in your page using the helper is pretty straight-forward.
            The only required argument is the resource <acronym class="acronym">URI</acronym>.
        </p></div>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;htmlFlash(&#039;/path/to/flash.swf&#039;); ?&gt;
</pre>


        <div class="example-contents"><p>
            This outputs the following <acronym class="acronym">HTML</acronym>:
        </p></div>

        <pre class="programlisting brush: html">
&lt;object data=&quot;/path/to/flash.swf&quot;
        type=&quot;application/x-shockwave-flash&quot;
        classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;
        codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab&quot;&gt;
&lt;/object&gt;
</pre>

    </div>

    <p class="para">
        Additionally you can specify attributes, parameters and content that can
        be rendered along with the <em class="emphasis">
&lt;object&gt;</em>. This will
        be demonstrated using the  <span class="methodname">htmlObject()</span> helper.
    </p>

    <div class="example" id="zend.view.helpers.initial.object.object"><div class="info"><p><b>Example #30 Customizing the object by passing additional arguments</b></p></div>
        

        <div class="example-contents"><p>
            The first argument in the object helpers is always required. It is
            the <acronym class="acronym">URI</acronym> to the resource you want to embed. The second argument is
            only required in the  <span class="methodname">htmlObject()</span> helper. The other helpers
            already contain the correct value for this argument. The third
            argument is used for passing along attributes to the object element.
            It only accepts an array with key-value pairs. <span class="property">classid</span>
            and <span class="property">codebase</span> are examples of such attributes. The fourth
            argument also only takes a key-value array and uses them to create
            <em class="emphasis">
&lt;param&gt;</em> elements. You will see an example
            of this shortly. Lastly, there is the option of providing additional
            content to the object. Now for an example which utilizes all arguments.
        </p></div>

        <pre class="programlisting brush: php">
echo $this-&gt;htmlObject(
    &#039;/path/to/file.ext&#039;,
    &#039;mime/type&#039;,
    array(
        &#039;attr1&#039; =&gt; &#039;aval1&#039;,
        &#039;attr2&#039; =&gt; &#039;aval2&#039;
    ),
    array(
        &#039;param1&#039; =&gt; &#039;pval1&#039;,
        &#039;param2&#039; =&gt; &#039;pval2&#039;
    ),
    &#039;some content&#039;
);

/*
This would output:

&lt;object data=&quot;/path/to/file.ext&quot; type=&quot;mime/type&quot;
    attr1=&quot;aval1&quot; attr2=&quot;aval2&quot;&gt;
    &lt;param name=&quot;param1&quot; value=&quot;pval1&quot; /&gt;
    &lt;param name=&quot;param2&quot; value=&quot;pval2&quot; /&gt;
    some content
&lt;/object&gt;
*/
</pre>

    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.inlinescript"><div class="info"><h1 class="title">InlineScript Helper</h1></div>
    

    <p class="para">
        The <acronym class="acronym">HTML</acronym> <em class="emphasis">&lt;script&gt;</em> element is used to either
        provide inline client-side scripting elements or link to a remote resource
        containing client-side scripting code. The <span class="classname">InlineScript</span>
        helper allows you to manage both. It is derived from <a href="zend.view.helpers.html#zend.view.helpers.initial.headscript" class="link">HeadScript</a>,
        and any method of that helper is available; however, use the
         <span class="methodname">inlineScript()</span> method in place of
         <span class="methodname">headScript()</span>.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Use InlineScript for HTML Body Scripts</b><br /></span>
        

        <p class="para">
            <span class="classname">InlineScript</span>, should be used when you wish to include
            scripts inline in the <acronym class="acronym">HTML</acronym> <em class="emphasis">body</em>. Placing scripts
            at the end of your document is a good practice for speeding up delivery of
            your page, particularly when using 3rd party analytics scripts.
        </p>

        <p class="para">
            Some JS libraries need to be included in the <acronym class="acronym">HTML</acronym>
            <em class="emphasis">head</em>; use <a href="zend.view.helpers.html#zend.view.helpers.initial.headscript" class="link">HeadScript</a> for those scripts.
        </p>
    </p></blockquote>
</div>
        <div class="section" id="zend.view.helpers.initial.json"><div class="info"><h1 class="title">JSON Helper</h1></div>
    

    <p class="para">
        When creating views that return <acronym class="acronym">JSON</acronym>, it&#039;s important to also set the
        appropriate response header. The <acronym class="acronym">JSON</acronym> view helper does exactly that. In
        addition, by default, it disables layouts (if currently enabled), as
        layouts generally aren&#039;t used with <acronym class="acronym">JSON</acronym> responses.
    </p>

    <p class="para">
        The <acronym class="acronym">JSON</acronym> helper sets the following header:
    </p>

    <pre class="programlisting brush: text">
Content-Type: application/json
</pre>


    <p class="para">
        Most <acronym class="acronym">AJAX</acronym> libraries look for this header when parsing responses to
        determine how to handle the content.
    </p>

    <p class="para">
        Usage of the <acronym class="acronym">JSON</acronym> helper is very straightforward:
    </p>

    <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;json($this-&gt;data) ?&gt;
</pre>


    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Keeping layouts and enabling encoding using Zend_Json_Expr</b><br /></span>
        

        <p class="para">
            Each method in the <acronym class="acronym">JSON</acronym> helper accepts a second, optional argument.
            This second argument can be a boolean flag to enable or disable
            layouts, or an array of options that will be passed to
             <span class="methodname">Zend_Json::encode()</span> and used internally to encode data.
        </p>

        <p class="para">
            To keep layouts, the second parameter needs to be boolean
            <b><tt>TRUE</tt></b>. When the second parameter is an array, keeping
            layouts can be achieved by including a <span class="property">keepLayouts</span> key
            with a value of a boolean <b><tt>TRUE</tt></b>.
        </p>

        <pre class="programlisting brush: php">
// Boolean true as second argument enables layouts:
echo $this-&gt;json($this-&gt;data, true);

// Or boolean true as &quot;keepLayouts&quot; key:
echo $this-&gt;json($this-&gt;data, array(&#039;keepLayouts&#039; =&gt; true));
</pre>


        <p class="para">
            <span class="classname">Zend_Json::encode</span> allows the encoding of native
            <acronym class="acronym">JSON</acronym> expressions using <span class="classname">Zend_Json_Expr</span> objects.
            This option is disabled by default. To enable this option, pass a boolean
            <b><tt>TRUE</tt></b> to the <span class="property">enableJsonExprFinder</span> key of
            the options array:
        </p>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;json($this-&gt;data, array(
    &#039;enableJsonExprFinder&#039; =&gt; true,
    &#039;keepLayouts&#039;          =&gt; true,
)) ?&gt;
</pre>

    </p></blockquote>
</div>
        <div class="section" id="zend.view.helpers.initial.navigation"><div class="info"><h1 class="title">Navigation Helpers</h1></div>
    

    <p class="para">
        The navigation helpers are used for rendering navigational elements
        from <a href="zend.navigation.containers.html" class="link">Zend_Navigation_Container</a>
        instances.
    </p>

    <p class="para">
        There are 5 built-in helpers:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.breadcrumbs" class="link">Breadcrumbs</a>,
                used for rendering the path to the currently active page.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.links" class="link">Links</a>,
                used for rendering navigational head links (e.g.
                <strong class="command">&lt;link rel=&quot;next&quot; href=&quot;...&quot; /&gt;</strong>)
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.menu" class="link">Menu</a>,
                used for rendering menus.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.sitemap" class="link">Sitemap</a>,
                used for rendering sitemaps conforming to the <a href="http://www.sitemaps.org/protocol.php" class="link external">&raquo; Sitemaps <acronym class="acronym">XML</acronym>
                    format</a>.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.navigation" class="link">Navigation</a>,
                used for proxying calls to other navigational helpers.
            </p>
        </li>
    </ul>

    <p class="para">
        All built-in helpers extend
        <span class="classname">Zend_View_Helper_Navigation_HelperAbstract</span>, which
        adds integration with <a href="zend.acl.html" class="link">ACL</a> and
        <a href="zend.translate.html" class="link">translation</a>. The abstract class
        implements the interface
        <span class="classname">Zend_View_Helper_Navigation_Helper</span>, which
        defines the following methods:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                 <span class="methodname">getContainer()</span> and  <span class="methodname">setContainer()</span>
                gets and sets the navigation container the helper should operate on by default, and
                 <span class="methodname">hasContainer()</span> checks if the helper
                has container registered.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">getTranslator()</span> and
                 <span class="methodname">setTranslator()</span> gets and sets the
                translator used for translating labels and titles.
                 <span class="methodname">getUseTranslator()</span> and
                 <span class="methodname">setUseTranslator()</span> controls whether
                the translator should be enabled. The method
                 <span class="methodname">hasTranslator()</span> checks if the helper has
                a translator registered.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">getAcl()</span>,  <span class="methodname">setAcl()</span>,
                 <span class="methodname">getRole()</span> and  <span class="methodname">setRole()</span>,
                gets and sets <acronym class="acronym">ACL</acronym> (<span class="classname">Zend_Acl</span>) instance and
                role (<span class="type">String</span> or
                <span class="classname">Zend_Acl_Role_Interface</span>) used for
                filtering out pages when rendering.  <span class="methodname">getUseAcl()</span> and
                 <span class="methodname">setUseAcl()</span> controls whether <acronym class="acronym">ACL</acronym> should
                be enabled. The methods  <span class="methodname">hasAcl()</span> and
                 <span class="methodname">hasRole()</span> checks if the helper has an
                <acronym class="acronym">ACL</acronym> instance or a role registered.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">__toString()</span>, magic method to ensure that
                helpers can be rendered by echoing the helper instance directly.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">render()</span>, must be implemented by concrete
                helpers to do the actual rendering.
            </p>
        </li>
     </ul>

    <p class="para">
         In addition to the method stubs from the interface, the abstract
         class also implements the following methods:
    </p>

     <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                 <span class="methodname">getIndent()</span> and  <span class="methodname">setIndent()</span>
                gets and sets indentation. The setter accepts a <span class="type">String</span> or an
                <span class="type">Integer</span>. In the case of an <span class="type">Integer</span>, the helper will use
                the given number of spaces for indentation. I.e.,
                 <span class="methodname">setIndent(4)</span> means 4 initial spaces of
                indentation. Indentation can be specified for all helpers
                except the Sitemap helper.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">getMinDepth()</span> and  <span class="methodname">setMinDepth()</span>
                gets and sets the minimum depth a page must have to be included by the helper.
                Setting <b><tt>NULL</tt></b> means no minimum depth.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">getMaxDepth()</span> and  <span class="methodname">setMaxDepth()</span>
                gets and sets the maximum depth a page can have to be included by the helper.
                Setting <b><tt>NULL</tt></b> means no maximum depth.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">getRenderInvisible()</span> and
                 <span class="methodname">setRenderInvisible()</span> gets and sets whether to
                render items that have been marked as invisible or not.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">__call()</span> is used for proxying calls to the
                container registered in the helper, which means you can
                call methods on a helper as if it was a container. See <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.proxy.example" class="link">example</a>
                below.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">findActive($container, $minDepth, $maxDepth)</span>
                is used for finding the deepest active page in the given
                container. If depths are not given, the method will use
                the values retrieved from  <span class="methodname">getMinDepth()</span> and
                 <span class="methodname">getMaxDepth()</span>. The deepest active page must
                be between <var class="varname">$minDepth</var> and <var class="varname">$maxDepth</var>
                inclusively. Returns an array containing a reference to the
                found page instance and the depth at which the page was
                found.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">htmlify()</span> renders an <em class="emphasis">&#039;a&#039;</em>
                <acronym class="acronym">HTML</acronym> element from a <span class="classname">Zend_Navigation_Page</span>
                instance.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                 <span class="methodname">accept()</span> is used for determining if a page
                should be accepted when iterating containers. This method
                checks for page visibility and verifies that the helper&#039;s
                role is allowed access to the page&#039;s resource and privilege.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                The static method  <span class="methodname">setDefaultAcl()</span> is used for setting
                a default <acronym class="acronym">ACL</acronym> object that will be used by helpers.
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                The static method  <span class="methodname">setDefaultRole()</span> is used for setting
                a default <acronym class="acronym">ACL</acronym> that will be used by helpers
            </p>
        </li>
    </ul>

    <p class="para">
        If a navigation container is not explicitly set in a helper using
        <strong class="command">$helper-&gt;setContainer($nav)</strong>, the helper will look
        for a container instance with the key <span class="classname">Zend_Navigation</span> in
        <a href="zend.registry.html" class="link">the registry</a>.
        If a container is not explicitly set or found in the registry, the
        helper will create an empty <span class="classname">Zend_Navigation</span>
        container when calling <strong class="command">$helper-&gt;getContainer()</strong>.
    </p>

    <div class="example" id="zend.view.helpers.initial.navigation.proxy.example"><div class="info"><p><b>Example #31 Proxying calls to the navigation container</b></p></div>
        

        <div class="example-contents"><p>
            Navigation view helpers use the magic method  <span class="methodname">__call()</span>
            to proxy method calls to the navigation container that is
            registered in the view helper.
        </p></div>

        <pre class="programlisting brush: php">
$this-&gt;navigation()-&gt;addPage(array(
    &#039;type&#039; =&gt; &#039;uri&#039;,
    &#039;label&#039; =&gt; &#039;New page&#039;));
</pre>


        <div class="example-contents"><p>
            The call above will add a page to the container in the
            <span class="classname">Navigation</span> helper.
        </p></div>
    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.i18n"><div class="info"><h1 class="title">Translation of labels and titles</h1></div>
        

        <p class="para">
            The navigation helpers support translation of page labels and titles.
            You can set a translator of type <span class="classname">Zend_Translate</span>
            or <span class="classname">Zend_Translate_Adapter</span> in the helper using
            <strong class="command">$helper-&gt;setTranslator($translator)</strong>, or like with other
            I18n-enabled components; by adding the translator to
            <a href="zend.registry.html" class="link">the registry</a> by using the key
            <span class="classname">Zend_Translate</span>.
        </p>

        <p class="para">
            If you want to disable translation, use
            <strong class="command">$helper-&gt;setUseTranslator(false)</strong>.
        </p>

        <p class="para">
            The
            <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.navigation" class="link">proxy
            helper</a> will inject its own translator to the helper it
            proxies to if the proxied helper doesn&#039;t already have a translator.
        </p>

        <blockquote class="note"><p><b class="note">Note</b>: 
            <p class="para">
                There is no translation in the sitemap helper, since there
                are no page labels or titles involved in an <acronym class="acronym">XML</acronym> sitemap.
            </p>
        </p></blockquote>
    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.acl"><div class="info"><h1 class="title">Integration with ACL</h1></div>
        

        <p class="para">
            All navigational view helpers support <acronym class="acronym">ACL</acronym> inherently from the
            class <span class="classname">Zend_View_Helper_Navigation_HelperAbstract</span>.
            A <span class="classname">Zend_Acl</span> object can be assigned to
            a helper instance with <code class="code">$helper-&gt;setAcl($acl)</code>, and role
            with <code class="code">$helper-&gt;setRole(&#039;member&#039;)</code> or
            <code class="code">$helper-&gt;setRole(new Zend_Acl_Role(&#039;member&#039;))</code> . If <acronym class="acronym">ACL</acronym>
            is used in the helper, the role in the helper must be allowed by
            the <acronym class="acronym">ACL</acronym> to access a page&#039;s <code class="code">resource</code> and/or have the
            page&#039;s <code class="code">privilege</code> for the page to be included when
            rendering.
        </p>

        <p class="para">
            If a page is not accepted by <acronym class="acronym">ACL</acronym>, any descendant page will also
            be excluded from rendering.
        </p>

        <p class="para">
            The
            <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.navigation" class="link">proxy
            helper</a> will inject its own <acronym class="acronym">ACL</acronym> and role to the helper it
            proxies to if the proxied helper doesn&#039;t already have any.
        </p>

        <p class="para">
            The examples below all show how <acronym class="acronym">ACL</acronym> affects rendering.
        </p>
    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.setup"><div class="info"><h1 class="title">Navigation setup used in examples</h1></div>
        

        <p class="para">
            This example shows the setup of a navigation container for a
            fictional software company.
        </p>

        <p class="para">
            Notes on the setup:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    The domain for the site is <code class="code">www.example.com</code>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    Interesting page properties are marked with a comment.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    Unless otherwise is stated in other examples, the user
                    is requesting the <acronym class="acronym">URL</acronym>
                    <code class="code">http://www.example.com/products/server/faq/</code>,
                    which translates to the page labeled <b><tt>FAQ</tt></b>
                    under <code class="code">Foo Server</code>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The assumed <acronym class="acronym">ACL</acronym> and router setup is shown below the
                    container setup.
                </p>
            </li>
        </ul>

        <pre class="programlisting brush: php">
/*
 * Navigation container (config/array)

 * Each element in the array will be passed to
 * Zend_Navigation_Page::factory() when constructing
 * the navigation container below.
 */
$pages = array(
    array(
        &#039;label&#039;      =&gt; &#039;Home&#039;,
        &#039;title&#039;      =&gt; &#039;Go Home&#039;,
        &#039;module&#039;     =&gt; &#039;default&#039;,
        &#039;controller&#039; =&gt; &#039;index&#039;,
        &#039;action&#039;     =&gt; &#039;index&#039;,
        &#039;order&#039;      =&gt; -100 // make sure home is the first page
    ),
    array(
        &#039;label&#039;      =&gt; &#039;Special offer this week only!&#039;,
        &#039;module&#039;     =&gt; &#039;store&#039;,
        &#039;controller&#039; =&gt; &#039;offer&#039;,
        &#039;action&#039;     =&gt; &#039;amazing&#039;,
        &#039;visible&#039;    =&gt; false // not visible
    ),
    array(
        &#039;label&#039;      =&gt; &#039;Products&#039;,
        &#039;module&#039;     =&gt; &#039;products&#039;,
        &#039;controller&#039; =&gt; &#039;index&#039;,
        &#039;action&#039;     =&gt; &#039;index&#039;,
        &#039;pages&#039;      =&gt; array(
            array(
                &#039;label&#039;      =&gt; &#039;Foo Server&#039;,
                &#039;module&#039;     =&gt; &#039;products&#039;,
                &#039;controller&#039; =&gt; &#039;server&#039;,
                &#039;action&#039;     =&gt; &#039;index&#039;,
                &#039;pages&#039;      =&gt; array(
                    array(
                        &#039;label&#039;      =&gt; &#039;FAQ&#039;,
                        &#039;module&#039;     =&gt; &#039;products&#039;,
                        &#039;controller&#039; =&gt; &#039;server&#039;,
                        &#039;action&#039;     =&gt; &#039;faq&#039;,
                        &#039;rel&#039;        =&gt; array(
                            &#039;canonical&#039; =&gt; &#039;http://www.example.com/?page=faq&#039;,
                            &#039;alternate&#039; =&gt; array(
                                &#039;module&#039;     =&gt; &#039;products&#039;,
                                &#039;controller&#039; =&gt; &#039;server&#039;,
                                &#039;action&#039;     =&gt; &#039;faq&#039;,
                                &#039;params&#039;     =&gt; array(&#039;format&#039; =&gt; &#039;xml&#039;)
                            )
                        )
                    ),
                    array(
                        &#039;label&#039;      =&gt; &#039;Editions&#039;,
                        &#039;module&#039;     =&gt; &#039;products&#039;,
                        &#039;controller&#039; =&gt; &#039;server&#039;,
                        &#039;action&#039;     =&gt; &#039;editions&#039;
                    ),
                    array(
                        &#039;label&#039;      =&gt; &#039;System Requirements&#039;,
                        &#039;module&#039;     =&gt; &#039;products&#039;,
                        &#039;controller&#039; =&gt; &#039;server&#039;,
                        &#039;action&#039;     =&gt; &#039;requirements&#039;
                    )
                )
            ),
            array(
                &#039;label&#039;      =&gt; &#039;Foo Studio&#039;,
                &#039;module&#039;     =&gt; &#039;products&#039;,
                &#039;controller&#039; =&gt; &#039;studio&#039;,
                &#039;action&#039;     =&gt; &#039;index&#039;,
                &#039;pages&#039;      =&gt; array(
                    array(
                        &#039;label&#039;      =&gt; &#039;Customer Stories&#039;,
                        &#039;module&#039;     =&gt; &#039;products&#039;,
                        &#039;controller&#039; =&gt; &#039;studio&#039;,
                        &#039;action&#039;     =&gt; &#039;customers&#039;
                    ),
                    array(
                        &#039;label&#039;      =&gt; &#039;Support&#039;,
                        &#039;module&#039;     =&gt; &#039;prodcts&#039;,
                        &#039;controller&#039; =&gt; &#039;studio&#039;,
                        &#039;action&#039;     =&gt; &#039;support&#039;
                    )
                )
            )
        )
    ),
    array(
        &#039;label&#039;      =&gt; &#039;Company&#039;,
        &#039;title&#039;      =&gt; &#039;About us&#039;,
        &#039;module&#039;     =&gt; &#039;company&#039;,
        &#039;controller&#039; =&gt; &#039;about&#039;,
        &#039;action&#039;     =&gt; &#039;index&#039;,
        &#039;pages&#039;      =&gt; array(
            array(
                &#039;label&#039;      =&gt; &#039;Investor Relations&#039;,
                &#039;module&#039;     =&gt; &#039;company&#039;,
                &#039;controller&#039; =&gt; &#039;about&#039;,
                &#039;action&#039;     =&gt; &#039;investors&#039;
            ),
            array(
                &#039;label&#039;      =&gt; &#039;News&#039;,
                &#039;class&#039;      =&gt; &#039;rss&#039;, // class
                &#039;module&#039;     =&gt; &#039;company&#039;,
                &#039;controller&#039; =&gt; &#039;news&#039;,
                &#039;action&#039;     =&gt; &#039;index&#039;,
                &#039;pages&#039;      =&gt; array(
                    array(
                        &#039;label&#039;      =&gt; &#039;Press Releases&#039;,
                        &#039;module&#039;     =&gt; &#039;company&#039;,
                        &#039;controller&#039; =&gt; &#039;news&#039;,
                        &#039;action&#039;     =&gt; &#039;press&#039;
                    ),
                    array(
                        &#039;label&#039;      =&gt; &#039;Archive&#039;,
                        &#039;route&#039;      =&gt; &#039;archive&#039;, // route
                        &#039;module&#039;     =&gt; &#039;company&#039;,
                        &#039;controller&#039; =&gt; &#039;news&#039;,
                        &#039;action&#039;     =&gt; &#039;archive&#039;
                    )
                )
            )
        )
    ),
    array(
        &#039;label&#039;      =&gt; &#039;Community&#039;,
        &#039;module&#039;     =&gt; &#039;community&#039;,
        &#039;controller&#039; =&gt; &#039;index&#039;,
        &#039;action&#039;     =&gt; &#039;index&#039;,
        &#039;pages&#039;      =&gt; array(
            array(
                &#039;label&#039;      =&gt; &#039;My Account&#039;,
                &#039;module&#039;     =&gt; &#039;community&#039;,
                &#039;controller&#039; =&gt; &#039;account&#039;,
                &#039;action&#039;     =&gt; &#039;index&#039;,
                &#039;resource&#039;   =&gt; &#039;mvc:community.account&#039; // resource
            ),
            array(
                &#039;label&#039; =&gt; &#039;Forums&#039;,
                &#039;uri&#039;   =&gt; &#039;http://forums.example.com/&#039;,
                &#039;class&#039; =&gt; &#039;external&#039; // class
            )
        )
    ),
    array(
        &#039;label&#039;      =&gt; &#039;Administration&#039;,
        &#039;module&#039;     =&gt; &#039;admin&#039;,
        &#039;controller&#039; =&gt; &#039;index&#039;,
        &#039;action&#039;     =&gt; &#039;index&#039;,
        &#039;resource&#039;   =&gt; &#039;mvc:admin&#039;, // resource
        &#039;pages&#039;      =&gt; array(
            array(
                &#039;label&#039;      =&gt; &#039;Write new article&#039;,
                &#039;module&#039;     =&gt; &#039;admin&#039;,
                &#039;controller&#039; =&gt; &#039;post&#039;,
                &#039;aciton&#039;     =&gt; &#039;write&#039;
            )
        )
    )
);

// Create container from array
$container = new Zend_Navigation($pages);

// Store the container in the proxy helper:
$view-&gt;getHelper(&#039;navigation&#039;)-&gt;setContainer($container);

// ...or simply:
$view-&gt;navigation($container);

// ...or store it in the reigstry:
Zend_Registry::set(&#039;Zend_Navigation&#039;, $container);
</pre>


        <p class="para">
            In addition to the container above, the following setup is assumed:
        </p>

        <pre class="programlisting brush: php">
// Setup router (default routes and &#039;archive&#039; route):
$front = Zend_Controller_Front::getInstance();
$router = $front-&gt;getRouter();
$router-&gt;addDefaultRoutes();
$router-&gt;addRoute(
    &#039;archive&#039;,
    new Zend_Controller_Router_Route(
        &#039;/archive/:year&#039;,
        array(
            &#039;module&#039;     =&gt; &#039;company&#039;,
            &#039;controller&#039; =&gt; &#039;news&#039;,
            &#039;action&#039;     =&gt; &#039;archive&#039;,
            &#039;year&#039;       =&gt; (int) date(&#039;Y&#039;) - 1
        ),
        array(&#039;year&#039; =&gt; &#039;\d+&#039;)
    )
);

// Setup ACL:
$acl = new Zend_Acl();
$acl-&gt;addRole(new Zend_Acl_Role(&#039;member&#039;));
$acl-&gt;addRole(new Zend_Acl_Role(&#039;admin&#039;));
$acl-&gt;add(new Zend_Acl_Resource(&#039;mvc:admin&#039;));
$acl-&gt;add(new Zend_Acl_Resource(&#039;mvc:community.account&#039;));
$acl-&gt;allow(&#039;member&#039;, &#039;mvc:community.account&#039;);
$acl-&gt;allow(&#039;admin&#039;, null);

// Store ACL and role in the proxy helper:
$view-&gt;navigation()-&gt;setAcl($acl)-&gt;setRole(&#039;member&#039;);

// ...or set default ACL and role statically:
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(&#039;member&#039;);
</pre>

    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.breadcrumbs"><div class="info"><h1 class="title">Breadcrumbs Helper</h1></div>
        

        <p class="para">
            Breadcrumbs are used for indicating where in a sitemap
            a user is currently browsing, and are typically rendered
            like this: &quot;You are here: Home &gt; Products &gt; FantasticProduct 1.0&quot;.
            The breadcrumbs helper follows the guidelines from <a href="http://developer.yahoo.com/ypatterns/pattern.php?pattern=breadcrumbs" class="link external">&raquo; Breadcrumbs
                Pattern - Yahoo! Design Pattern Library</a>,
            and allows simple customization (minimum/maximum depth, indentation,
            separator, and whether the last element should be linked), or
            rendering using a partial view script.
        </p>

        <p class="para">
            The Breadcrumbs helper works like this; it finds the deepest active
            page in a navigation container, and renders an upwards path to
            the root. For <acronym class="acronym">MVC</acronym> pages, the &quot;activeness&quot; of a page is
            determined by inspecting the request object, as stated in the
            section on <a href="zend.navigation.pages.html#zend.navigation.pages.mvc" class="link">Zend_Navigation_Page_Mvc</a>.
        </p>

        <p class="para">
            The helper sets the <code class="code">minDepth</code> property to 1 by default,
            meaning breadcrumbs will not be rendered if the deepest active page
            is a root page. If <code class="code">maxDepth</code> is specified, the helper
            will stop rendering when at the specified depth (e.g. stop at level
            2 even if the deepest active page is on level 3).
        </p>

        <p class="para">
            Methods in the breadcrumbs helper:
        </p>

        <ul class="itemizedlist">
           <li class="listitem">
               <p class="para">
                   <code class="code">{get|set}Separator()</code> gets/sets separator
                   string that is used between breadcrumbs. Defualt is
                   <code class="code">&#039; &amp;gt; &#039;</code>.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                   <code class="code">{get|set}LinkLast()</code> gets/sets whether the
                   last breadcrumb should be rendered as an anchor or not.
                   Default is <b><tt>FALSE</tt></b>.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                   <code class="code">{get|set}Partial()</code> gets/sets a partial view
                   script that should be used for rendering breadcrumbs.
                   If a partial view script is set, the helper&#039;s
                    <span class="methodname">render()</span> method will use the
                    <span class="methodname">renderPartial()</span> method. If no partial is
                   set, the  <span class="methodname">renderStraight()</span> method is used.
                   The helper expects the partial to be a <span class="type">String</span>
                   or an <span class="type">Array</span> with two elements. If the partial
                   is a <span class="type">String</span>, it denotes the name of the partial
                   script to use. If it is an <span class="type">Array</span>, the first
                   element will be used as the name of the partial view
                   script, and the second element is the module where the
                   script is found.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                    <span class="methodname">renderStraight()</span> is the default render
                   method.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                    <span class="methodname">renderPartial()</span> is used for rendering
                   using a partial view script.
               </p>
           </li>
       </ul>

        <div class="example" id="zend.view.helpers.initial.navigation.breadcrumbs.example1"><div class="info"><p><b>Example #32 Rendering breadcrumbs</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render breadcrumbs with default
                settings.
            </p></div>

            <pre class="programlisting brush: php">
In a view script or layout:
&lt;?php echo $this-&gt;navigation()-&gt;breadcrumbs(); ?&gt;

The two calls above take advantage of the magic __toString() method,
and are equivalent to:
&lt;?php echo $this-&gt;navigation()-&gt;breadcrumbs()-&gt;render(); ?&gt;

Output:
&lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt; &amp;gt; &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt; &amp;gt; FAQ
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.breadcrumbs.example2"><div class="info"><p><b>Example #33 Specifying indentation</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render breadcrumbs with initial
                indentation.
            </p></div>

            <pre class="programlisting brush: php">
Rendering with 8 spaces indentation:
&lt;?php echo $this-&gt;navigation()-&gt;breadcrumbs()-&gt;setIndent(8);?&gt;

Output:
        &lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt; &amp;gt; &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt; &amp;gt; FAQ
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.breadcrumbs.example3"><div class="info"><p><b>Example #34 Customize breadcrumbs output</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to customze breadcrumbs output by
                specifying various options.
            </p></div>

            <pre class="programlisting brush: php">
In a view script or layout:

&lt;?php
echo $this-&gt;navigation()
          -&gt;breadcrumbs()
          -&gt;setLinkLast(true)                   // link last page
          -&gt;setMaxDepth(1)                      // stop at level 1
          -&gt;setSeparator(&#039; &amp;#9654;&#039; . PHP_EOL); // cool separator with newline
?&gt;

Output:
&lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt; &amp;#9654;
&lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;

/////////////////////////////////////////////////////

Setting minimum depth required to render breadcrumbs:

&lt;?php
$this-&gt;navigation()-&gt;breadcrumbs()-&gt;setMinDepth(10);
echo $this-&gt;navigation()-&gt;breadcrumbs();
?&gt;

Output:
Nothing, because the deepest active page is not at level 10 or deeper.
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.breadcrumbs.example4"><div class="info"><p><b>Example #35 Rendering breadcrumbs using a partial view script</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render customized breadcrumbs using
                a partial vew script. By calling  <span class="methodname">setPartial()</span>,
                you can specify a partial view script that will be used
                when calling  <span class="methodname">render()</span>. When a partial is specified,
                the  <span class="methodname">renderPartial()</span> method will be called. This
                method will find the deepest active page and pass an array
                of pages that leads to the active page to the partial view
                script.
            </p></div>

            <div class="example-contents"><p>
                In a layout:
            </p></div>

            <pre class="programlisting brush: php">
$partial = ;
echo $this-&gt;navigation()-&gt;breadcrumbs()
                        -&gt;setPartial(array(&#039;breadcrumbs.phtml&#039;, &#039;default&#039;));
</pre>


            <div class="example-contents"><p>
                Contents of
                <code class="code">application/modules/default/views/breadcrumbs.phtml</code>:
            </p></div>

            <pre class="programlisting brush: php">
echo implode(&#039;, &#039;, array_map(
        create_function(&#039;$a&#039;, &#039;return $a-&gt;getLabel();&#039;),
        $this-&gt;pages));
</pre>


            <div class="example-contents"><p>
                Output:
            </p></div>

            <pre class="programlisting brush: php">
Products, Foo Server, FAQ
</pre>

        </div>
    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.links"><div class="info"><h1 class="title">Links Helper</h1></div>
        

        <p class="para">
            The links helper is used for rendering <acronym class="acronym">HTML</acronym> <b><tt>LINK</tt></b>
            elements. Links are used for describing document relationships
            of the currently active page. Read more about links and link
            types at <a href="http://www.w3.org/TR/html4/struct/links.html#h-12.3" class="link external">&raquo; Document
                relationships: the LINK element (HTML4 W3C Rec.)</a>
            and <a href="http://www.w3.org/TR/html4/types.html#h-6.12" class="link external">&raquo; Link types (HTML4 W3C
                Rec.)</a> in the <acronym class="acronym">HTML</acronym>4 W3C Recommendation.
        </p>

        <p class="para">
            There are two types of relations; forward and reverse, indicated
            by the keyords <code class="code">&#039;rel&#039;</code> and <code class="code">&#039;rev&#039;</code>. Most
            methods in the helper will take a <var class="varname">$rel</var> param, which
            must be either <code class="code">&#039;rel&#039;</code> or <code class="code">&#039;rev&#039;</code>. Most
            methods also take a <var class="varname">$type</var> param, which is used
            for specifying the link type (e.g. alternate, start, next, prev,
            chapter, etc).
        </p>

        <p class="para">
            Relationships can be added to page objects manually, or found
            by traversing the container registered in the helper. The method
             <span class="methodname">findRelation($page, $rel, $type)</span> will first try
            to find the given <var class="varname">$rel</var> of <var class="varname">$type</var> from
            the <var class="varname">$page</var> by calling <code class="code">$page-&gt;findRel($type)</code>
            or <code class="code">$page-&gt;findRel($type)</code>. If the <var class="varname">$page</var>
            has a relation that can be converted to a page instance, that
            relation will be used. If the <var class="varname">$page</var> instance doesn&#039;t
            have the specified <var class="varname">$type</var>, the helper will look for
            a method in the helper named <code class="code">search$rel$type</code> (e.g.
             <span class="methodname">searchRelNext()</span> or
             <span class="methodname">searchRevAlternate()</span>).
            If such a method exists, it will be used for determining the
            <var class="varname">$page</var>&#039;s relation by traversing the container.
        </p>

        <p class="para">
            Not all relations can be determined by traversing the container.
            These are the relations that will be found by searching:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRelStart()</span>, forward &#039;start&#039;
                    relation: the first page in the container.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRelNext()</span>, forward &#039;next&#039;
                    relation; finds the next page in the container, i.e.
                    the page after the active page.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRelPrev()</span>, forward &#039;prev&#039;
                    relation; finds the previous page, i.e. the page before
                    the active page.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRelChapter()</span>, forward &#039;chapter&#039;
                    relations; finds all pages on level 0 except the &#039;start&#039;
                    relation or the active page if it&#039;s on level 0.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRelSection()</span>, forward &#039;section&#039;
                    relations; finds all child pages of the active page if
                    the active page is on level 0 (a &#039;chapter&#039;).
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRelSubsection()</span>, forward &#039;subsection&#039;
                    relations; finds all child pages of the active page if
                    the active pages is on level 1 (a &#039;section&#039;).
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRevSection()</span>, reverse &#039;section&#039;
                    relation; finds the parent of the active page if the
                    active page is on level 1 (a &#039;section&#039;).
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">searchRevSubsection()</span>, reverse &#039;subsection&#039;
                    relation; finds the parent of the active page if the
                    active page is on level 2 (a &#039;subsection&#039;).
                </p>
            </li>
        </ul>

        <blockquote class="note"><p><b class="note">Note</b>: 
            <p class="para">
                When looking for relations in the page instance
                (<code class="code">$page-&gt;getRel($type)</code> or
                <code class="code">$page-&gt;getRev($type)</code>), the helper accepts the
                values of type <span class="type">String</span>, <span class="type">Array</span>,
                <span class="classname">Zend_Config</span>, or
                <span class="classname">Zend_Navigation_Page</span>. If a string
                is found, it will be converted to a
                <span class="classname">Zend_Navigation_Page_Uri</span>. If an array
                or a config is found, it will be converted to one or several
                page instances. If the first key of the array/config is numeric,
                it will be considered to contain several pages, and each
                element will be passed to the
                <a href="zend.navigation.pages.html#zend.navigation.pages.factory" class="link">page factory</a>.
                If the first key is not numeric, the array/config will be
                passed to the page factory directly, and a single page will
                be returned.
            </p>
        </p></blockquote>

        <p class="para">
            The helper also supports magic methods for finding relations.
            E.g. to find forward alternate relations, call
            <code class="code">$helper-&gt;findRelAlternate($page)</code>, and to find
            reverse section relations, call
            <code class="code">$helper-&gt;findRevSection($page)</code>. Those calls correspond
            to <code class="code">$helper-&gt;findRelation($page, &#039;rel&#039;, &#039;alternate&#039;);</code>
            and <code class="code">$helper-&gt;findRelation($page, &#039;rev&#039;, &#039;section&#039;);</code>
            respectively.
        </p>

        <p class="para">
            To customize which relations should be rendered, the helper
            uses a render flag. The render flag is an integer value, and will be
            used in a
            <a href="http://php.net/manual/en/language.operators.bitwise.php" class="link external">&raquo; bitwse
            <code class="code">and</code> (<code class="code">&amp;</code>) operation</a> against the
            helper&#039;s render constants to determine if the relation that belongs
            to the render constant should be rendered.
        </p>

        <p class="para">
            See the
            <a href="zend.view.helpers.html#zend.view.helpers.initial.navigation.links.example3" class="link">example
            below</a> for more information.
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_ALTERNATE</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_STYLESHEET</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_START</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_NEXT</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_PREV</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_CONTENTS</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_INDEX</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_GLOSSARY</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_COPYRIGHT</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_CHAPTER</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_SECTION</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_SUBSECTION</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_APPENDIX</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_HELP</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_BOOKMARK</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_CUSTOM</tt></b>
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <b><tt>Zend_View_Helper_Navigation_Link::RENDER_ALL</tt></b>
                </p>
            </li>
        </ul>

        <p class="para">
            The constants from <b><tt>RENDER_ALTERNATE</tt></b> to
            <b><tt>RENDER_BOOKMARK</tt></b> denote standard <acronym class="acronym">HTML</acronym> link types.
            <b><tt>RENDER_CUSTOM</tt></b> denotes non-standard relations that
            specified in pages. <b><tt>RENDER_ALL</tt></b> denotes standard and
            non-standard relations.
        </p>

        <p class="para">
            Methods in the links helper:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}RenderFlag()</code> gets/sets the render
                    flag. Default is <b><tt>RENDER_ALL</tt></b>. See examples
                    below on how to set the render flag.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">findAllRelations()</span> finds all relations of
                    all types for a given page.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">findRelation()</span> finds all relations of a given
                    type from a given page.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">searchRel{Start|Next|Prev|Chapter|Section|Subsection}()</code>
                    traverses a container to find forward relations to
                    the start page, the next page, the previous page,
                    chapters, sections, and subsections.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">searchRev{Section|Subsection}()</code> traverses
                    a container to find reverse relations to sections or
                    subsections.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">renderLink()</span> renders a single <code class="code">link</code>
                    element.
                </p>
            </li>
        </ul>

        <div class="example" id="zend.view.helpers.initial.navigation.links.example1"><div class="info"><p><b>Example #36 Specify relations in pages</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to specify relations in pages.
            </p></div>

            <pre class="programlisting brush: php">
$container = new Zend_Navigation(array(
    array(
        &#039;label&#039; =&gt; &#039;Relations using strings&#039;,
        &#039;rel&#039;   =&gt; array(
            &#039;alternate&#039; =&gt; &#039;http://www.example.org/&#039;
        ),
        &#039;rev&#039;   =&gt; array(
            &#039;alternate&#039; =&gt; &#039;http://www.example.net/&#039;
        )
    ),
    array(
        &#039;label&#039; =&gt; &#039;Relations using arrays&#039;,
        &#039;rel&#039;   =&gt; array(
            &#039;alternate&#039; =&gt; array(
                &#039;label&#039; =&gt; &#039;Example.org&#039;,
                &#039;uri&#039;   =&gt; &#039;http://www.example.org/&#039;
            )
        )
    ),
    array(
        &#039;label&#039; =&gt; &#039;Relations using configs&#039;,
        &#039;rel&#039;   =&gt; array(
            &#039;alternate&#039; =&gt; new Zend_Config(array(
                &#039;label&#039; =&gt; &#039;Example.org&#039;,
                &#039;uri&#039;   =&gt; &#039;http://www.example.org/&#039;
            ))
        )
    ),
    array(
        &#039;label&#039; =&gt; &#039;Relations using pages instance&#039;,
        &#039;rel&#039;   =&gt; array(
            &#039;alternate&#039; =&gt; Zend_Navigation_Page::factory(array(
                &#039;label&#039; =&gt; &#039;Example.org&#039;,
                &#039;uri&#039;   =&gt; &#039;http://www.example.org/&#039;
            ))
        )
    )
));
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.links.example2"><div class="info"><p><b>Example #37 Default rendering of links</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render a menu from a container
                registered/found in the view helper.
            </p></div>

            <pre class="programlisting brush: php">
In a view script or layout:
&lt;?php echo $this-&gt;view-&gt;navigation()-&gt;links(); ?&gt;

Output:
&lt;link rel=&quot;alternate&quot; href=&quot;/products/server/faq/format/xml&quot;&gt;
&lt;link rel=&quot;start&quot; href=&quot;/&quot; title=&quot;Home&quot;&gt;
&lt;link rel=&quot;next&quot; href=&quot;/products/server/editions&quot; title=&quot;Editions&quot;&gt;
&lt;link rel=&quot;prev&quot; href=&quot;/products/server&quot; title=&quot;Foo Server&quot;&gt;
&lt;link rel=&quot;chapter&quot; href=&quot;/products&quot; title=&quot;Products&quot;&gt;
&lt;link rel=&quot;chapter&quot; href=&quot;/company/about&quot; title=&quot;Company&quot;&gt;
&lt;link rel=&quot;chapter&quot; href=&quot;/community&quot; title=&quot;Community&quot;&gt;
&lt;link rel=&quot;canonical&quot; href=&quot;http://www.example.com/?page=server-faq&quot;&gt;
&lt;link rev=&quot;subsection&quot; href=&quot;/products/server&quot; title=&quot;Foo Server&quot;&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.links.example3"><div class="info"><p><b>Example #38 Specify which relations to render</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to specify which relations to find
                and render.
            </p></div>

            <pre class="programlisting brush: php">
Render only start, next, and prev:
$helper-&gt;setRenderFlag(Zend_View_Helper_Navigation_Links::RENDER_START |
                       Zend_View_Helper_Navigation_Links::RENDER_NEXT |
                       Zend_View_Helper_Navigation_Links::RENDER_PREV);

Output:
&lt;link rel=&quot;start&quot; href=&quot;/&quot; title=&quot;Home&quot;&gt;
&lt;link rel=&quot;next&quot; href=&quot;/products/server/editions&quot; title=&quot;Editions&quot;&gt;
&lt;link rel=&quot;prev&quot; href=&quot;/products/server&quot; title=&quot;Foo Server&quot;&gt;
</pre>


            <pre class="programlisting brush: php">
Render only native link types:
$helper-&gt;setRenderFlag(Zend_View_Helper_Navigation_Links::RENDER_ALL ^
                       Zend_View_Helper_Navigation_Links::RENDER_CUSTOM);

Output:
&lt;link rel=&quot;alternate&quot; href=&quot;/products/server/faq/format/xml&quot;&gt;
&lt;link rel=&quot;start&quot; href=&quot;/&quot; title=&quot;Home&quot;&gt;
&lt;link rel=&quot;next&quot; href=&quot;/products/server/editions&quot; title=&quot;Editions&quot;&gt;
&lt;link rel=&quot;prev&quot; href=&quot;/products/server&quot; title=&quot;Foo Server&quot;&gt;
&lt;link rel=&quot;chapter&quot; href=&quot;/products&quot; title=&quot;Products&quot;&gt;
&lt;link rel=&quot;chapter&quot; href=&quot;/company/about&quot; title=&quot;Company&quot;&gt;
&lt;link rel=&quot;chapter&quot; href=&quot;/community&quot; title=&quot;Community&quot;&gt;
&lt;link rev=&quot;subsection&quot; href=&quot;/products/server&quot; title=&quot;Foo Server&quot;&gt;
</pre>


            <pre class="programlisting brush: php">
Render all but chapter:
$helper-&gt;setRenderFlag(Zend_View_Helper_Navigation_Links::RENDER_ALL ^
                       Zend_View_Helper_Navigation_Links::RENDER_CHAPTER);

Output:
&lt;link rel=&quot;alternate&quot; href=&quot;/products/server/faq/format/xml&quot;&gt;
&lt;link rel=&quot;start&quot; href=&quot;/&quot; title=&quot;Home&quot;&gt;
&lt;link rel=&quot;next&quot; href=&quot;/products/server/editions&quot; title=&quot;Editions&quot;&gt;
&lt;link rel=&quot;prev&quot; href=&quot;/products/server&quot; title=&quot;Foo Server&quot;&gt;
&lt;link rel=&quot;canonical&quot; href=&quot;http://www.example.com/?page=server-faq&quot;&gt;
&lt;link rev=&quot;subsection&quot; href=&quot;/products/server&quot; title=&quot;Foo Server&quot;&gt;
</pre>

        </div>
    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.menu"><div class="info"><h1 class="title">Menu Helper</h1></div>
        

        <p class="para">
            The Menu helper is used for rendering menus from navigation
            containers. By default, the menu will be rendered using
            <acronym class="acronym">HTML</acronym> <code class="code">UL</code> and <code class="code">LI</code> tags, but the helper also
            allows using a partial view script.
        </p>

        <p class="para">
            Methods in the Menu helper:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}UlClass()</code> gets/sets the <acronym class="acronym">CSS</acronym> class
                    used in  <span class="methodname">renderMenu()</span>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}OnlyActiveBranch()</code> gets/sets a flag
                    specifying whether only the active branch of a container
                    should be rendered.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}RenderParents()</code> gets/sets a flag
                    specifying whether parents should be rendered when only
                    rendering active branch of a container. If set to
                    <b><tt>FALSE</tt></b>, only the deepest active menu will be
                    rendered.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}Partial()</code> gets/sets a partial view
                    script that should be used for rendering menu.
                    If a partial view script is set, the helper&#039;s
                     <span class="methodname">render()</span> method will use the
                     <span class="methodname">renderPartial()</span> method. If no partial is
                    set, the  <span class="methodname">renderMenu()</span> method is used.
                    The helper expects the partial to be a <span class="type">String</span>
                    or an <span class="type">Array</span> with two elements. If the partial
                    is a <span class="type">String</span>, it denotes the name of the partial
                    script to use. If it is an <span class="type">Array</span>, the first
                    element will be used as the name of the partial view
                    script, and the second element is the module where the
                    script is found.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">htmlify()</span> overrides the method from the
                    abstract class to return <code class="code">span</code> elements
                    if the page has no <code class="code">href</code>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">renderMenu($container = null, $options = array())</span>
                    is the default render method, and will render a container as
                    a <acronym class="acronym">HTML</acronym> <code class="code">UL</code> list.
                </p>

                <p class="para">
                    If <var class="varname">$container</var> is not given, the container
                    registered in the helper will be rendered.
                </p>

                <p class="para">
                    <var class="varname">$options</var> is used for overriding options
                    specified temporarily without rsetting the values in the
                    helper instance. It is an associative array where each key
                    corresponds to an option in the helper.
                </p>

                <p class="para">
                    Recognized options:
                </p>

                <ul class="itemizedlist">
                    <li class="listitem">
                        <p class="para">
                            <code class="code">indent</code>; indentation. Expects a
                            <span class="type">String</span> or an <code class="code">int</code>
                            value.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <code class="code">minDepth</code>; minimum depth. Expcects
                            an <code class="code">int</code> or <b><tt>NULL</tt></b> (no
                            minimum depth).
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <code class="code">maxDepth</code>; maximum depth. Expcects
                            an <code class="code">int</code> or <b><tt>NULL</tt></b> (no
                            maximum depth).
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <code class="code">ulClass</code>; <acronym class="acronym">CSS</acronym> class for
                            <code class="code">ul</code> element. Expects a
                            <span class="type">String</span>.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <code class="code">onlyActiveBranch</code>; whether only
                            active branch should be rendered. Expects
                            a <span class="type">Boolean</span> value.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <code class="code">renderParents</code>; whether parents
                            should be rendered if only rendering active
                            branch. Expects a <span class="type">Boolean</span> value.
                        </p>
                    </li>
                </ul>

                <p class="para">
                    If an option is not given, the value set in the helper
                    will be used.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">renderPartial()</span> is used for rendering the menu
                    using a partial view script.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                     <span class="methodname">renderSubMenu()</span> renders the deepest menu level
                    of a container&#039;s active branch.
                </p>
            </li>
       </ul>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example1"><div class="info"><p><b>Example #39 Rendering a menu</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render a menu from a container
                registered/found in the view helper. Notice how pages
                are filtered out based on visibility and <acronym class="acronym">ACL</acronym>.
            </p></div>

            <pre class="programlisting brush: php">
In a view script or layout:
&lt;?php echo $this-&gt;navigation()-&gt;menu()-&gt;render() ?&gt;

Or simply:
&lt;?php echo $this-&gt;navigation()-&gt;menu() ?&gt;

Output:
&lt;ul class=&quot;navigation&quot;&gt;
    &lt;li&gt;
        &lt;a title=&quot;Go Home&quot; href=&quot;/&quot;&gt;Home&lt;/a&gt;
    &lt;/li&gt;
    &lt;li class=&quot;active&quot;&gt;
        &lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt;
        &lt;ul&gt;
            &lt;li class=&quot;active&quot;&gt;
                &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;
                &lt;ul&gt;
                    &lt;li class=&quot;active&quot;&gt;
                        &lt;a href=&quot;/products/server/faq&quot;&gt;FAQ&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/products/server/editions&quot;&gt;Editions&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/products/server/requirements&quot;&gt;System Requirements&lt;/a&gt;
                    &lt;/li&gt;
                &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/studio&quot;&gt;Foo Studio&lt;/a&gt;
                &lt;ul&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/products/studio/customers&quot;&gt;Customer Stories&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/prodcts/studio/support&quot;&gt;Support&lt;/a&gt;
                    &lt;/li&gt;
                &lt;/ul&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a title=&quot;About us&quot; href=&quot;/company/about&quot;&gt;Company&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;a href=&quot;/company/about/investors&quot;&gt;Investor Relations&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a class=&quot;rss&quot; href=&quot;/company/news&quot;&gt;News&lt;/a&gt;
                &lt;ul&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/company/news/press&quot;&gt;Press Releases&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/archive&quot;&gt;Archive&lt;/a&gt;
                    &lt;/li&gt;
                &lt;/ul&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&quot;/community&quot;&gt;Community&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;a href=&quot;/community/account&quot;&gt;My Account&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a class=&quot;external&quot; href=&quot;http://forums.example.com/&quot;&gt;Forums&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example2"><div class="info"><p><b>Example #40 Calling renderMenu() directly</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render a menu that is not
                registered in the view helper by calling the
                 <span class="methodname">renderMenu()</span> directly and specifying a few
                options.
            </p></div>

            <pre class="programlisting brush: php">
&lt;?php
// render only the &#039;Community&#039; menu
$community = $this-&gt;navigation()-&gt;findOneByLabel(&#039;Community&#039;);
$options = array(
    &#039;indent&#039;  =&gt; 16,
    &#039;ulClass&#039; =&gt; &#039;community&#039;
);
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;renderMenu($community, $options);
?&gt;
Output:
                &lt;ul class=&quot;community&quot;&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/community/account&quot;&gt;My Account&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a class=&quot;external&quot; href=&quot;http://forums.example.com/&quot;&gt;Forums&lt;/a&gt;
                    &lt;/li&gt;
                &lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example3"><div class="info"><p><b>Example #41 Rendering the deepest active menu</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how the  <span class="methodname">renderSubMenu()</span>
                will render the deepest sub menu of the active branch.
            </p></div>

            <div class="example-contents"><p>
                Calling  <span class="methodname">renderSubMenu($container, $ulClass, $indent)</span>
                is equivalent to calling  <span class="methodname">renderMenu($container, $options)</span>
                with the following options:
            </p></div>

            <pre class="programlisting brush: php">
array(
    &#039;ulClass&#039;          =&gt; $ulClass,
    &#039;indent&#039;           =&gt; $indent,
    &#039;minDepth&#039;         =&gt; null,
    &#039;maxDepth&#039;         =&gt; null,
    &#039;onlyActiveBranch&#039; =&gt; true,
    &#039;renderParents&#039;    =&gt; false
);
</pre>


            <pre class="programlisting brush: php">
&lt;?php
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;renderSubMenu(null, &#039;sidebar&#039;, 4);
?&gt;

The output will be the same if &#039;FAQ&#039; or &#039;Foo Server&#039; is active:
    &lt;ul class=&quot;sidebar&quot;&gt;
        &lt;li class=&quot;active&quot;&gt;
            &lt;a href=&quot;/products/server/faq&quot;&gt;FAQ&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;/products/server/editions&quot;&gt;Editions&lt;/a&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;a href=&quot;/products/server/requirements&quot;&gt;System Requirements&lt;/a&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example4"><div class="info"><p><b>Example #42 Rendering a menu with maximum depth</b></p></div>
            

            <pre class="programlisting brush: php">
&lt;?php
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;setMaxDepth(1);
?&gt;

Output:
&lt;ul class=&quot;navigation&quot;&gt;
    &lt;li&gt;
        &lt;a title=&quot;Go Home&quot; href=&quot;/&quot;&gt;Home&lt;/a&gt;
    &lt;/li&gt;
    &lt;li class=&quot;active&quot;&gt;
        &lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt;
        &lt;ul&gt;
            &lt;li class=&quot;active&quot;&gt;
                &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/studio&quot;&gt;Foo Studio&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a title=&quot;About us&quot; href=&quot;/company/about&quot;&gt;Company&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;a href=&quot;/company/about/investors&quot;&gt;Investor Relations&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a class=&quot;rss&quot; href=&quot;/company/news&quot;&gt;News&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&quot;/community&quot;&gt;Community&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;a href=&quot;/community/account&quot;&gt;My Account&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a class=&quot;external&quot; href=&quot;http://forums.example.com/&quot;&gt;Forums&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example5"><div class="info"><p><b>Example #43 Rendering a menu with minimum depth</b></p></div>
            

            <pre class="programlisting brush: php">
&lt;?php
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;setMinDepth(1);
?&gt;

Output:
&lt;ul class=&quot;navigation&quot;&gt;
    &lt;li class=&quot;active&quot;&gt;
        &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;
        &lt;ul&gt;
            &lt;li class=&quot;active&quot;&gt;
                &lt;a href=&quot;/products/server/faq&quot;&gt;FAQ&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/server/editions&quot;&gt;Editions&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/server/requirements&quot;&gt;System Requirements&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&quot;/products/studio&quot;&gt;Foo Studio&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/studio/customers&quot;&gt;Customer Stories&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/prodcts/studio/support&quot;&gt;Support&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&quot;/company/about/investors&quot;&gt;Investor Relations&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a class=&quot;rss&quot; href=&quot;/company/news&quot;&gt;News&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;a href=&quot;/company/news/press&quot;&gt;Press Releases&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/archive&quot;&gt;Archive&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&quot;/community/account&quot;&gt;My Account&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a class=&quot;external&quot; href=&quot;http://forums.example.com/&quot;&gt;Forums&lt;/a&gt;
    &lt;/li&gt;
&lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example6"><div class="info"><p><b>Example #44 Rendering only the active branch of a menu</b></p></div>
            

            <pre class="programlisting brush: php">
&lt;?php
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;setOnlyActiveBranch(true);
?&gt;

Output:
&lt;ul class=&quot;navigation&quot;&gt;
    &lt;li class=&quot;active&quot;&gt;
        &lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt;
        &lt;ul&gt;
            &lt;li class=&quot;active&quot;&gt;
                &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;
                &lt;ul&gt;
                    &lt;li class=&quot;active&quot;&gt;
                        &lt;a href=&quot;/products/server/faq&quot;&gt;FAQ&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/products/server/editions&quot;&gt;Editions&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;/products/server/requirements&quot;&gt;System Requirements&lt;/a&gt;
                    &lt;/li&gt;
                &lt;/ul&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example7"><div class="info"><p><b>Example #45 
                Rendering only the active branch of a menu with minimum depth
            </b></p></div>
            

            <pre class="programlisting brush: php">
&lt;?php
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;setOnlyActiveBranch(true)
          -&gt;setMinDepth(1);
?&gt;

Output:
&lt;ul class=&quot;navigation&quot;&gt;
    &lt;li class=&quot;active&quot;&gt;
        &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;
        &lt;ul&gt;
            &lt;li class=&quot;active&quot;&gt;
                &lt;a href=&quot;/products/server/faq&quot;&gt;FAQ&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/server/editions&quot;&gt;Editions&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/server/requirements&quot;&gt;System Requirements&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example8"><div class="info"><p><b>Example #46 
                Rendering only the active branch of a menu with maximum depth
            </b></p></div>
            

            <pre class="programlisting brush: php">
&lt;?php
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;setOnlyActiveBranch(true)
          -&gt;setMaxDepth(1);
?&gt;

Output:
&lt;ul class=&quot;navigation&quot;&gt;
    &lt;li class=&quot;active&quot;&gt;
        &lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt;
        &lt;ul&gt;
            &lt;li class=&quot;active&quot;&gt;
                &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;a href=&quot;/products/studio&quot;&gt;Foo Studio&lt;/a&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example9"><div class="info"><p><b>Example #47 
                Rendering only the active branch of a menu with maximum depth
                and no parents
            </b></p></div>
            

            <div class="example-contents"><p>
            </p></div>

            <pre class="programlisting brush: php">
&lt;?php
echo $this-&gt;navigation()
          -&gt;menu()
          -&gt;setOnlyActiveBranch(true)
          -&gt;setRenderParents(false)
          -&gt;setMaxDepth(1);
?&gt;

Output:
&lt;ul class=&quot;navigation&quot;&gt;
    &lt;li class=&quot;active&quot;&gt;
        &lt;a href=&quot;/products/server&quot;&gt;Foo Server&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&quot;/products/studio&quot;&gt;Foo Studio&lt;/a&gt;
    &lt;/li&gt;
&lt;/ul&gt;
</pre>

        </div>

        <div class="example" id="zend.view.helpers.initial.navigation.menu.example10"><div class="info"><p><b>Example #48 Rendering a custom menu using a partial view script</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render a custom menu using
                a partial vew script. By calling  <span class="methodname">setPartial()</span>,
                you can specify a partial view script that will be used
                when calling  <span class="methodname">render()</span>. When a partial is specified,
                the  <span class="methodname">renderPartial()</span> method will be called. This
                method will assign the container to the view with the key
                <code class="code">container</code>.
            </p></div>

            <div class="example-contents"><p>In a layout:</p></div>

            <pre class="programlisting brush: php">
$partial = array(&#039;menu.phtml&#039;, &#039;default&#039;);
$this-&gt;navigation()-&gt;menu()-&gt;setPartial($partial);
echo $this-&gt;navigation()-&gt;menu()-&gt;render();
</pre>


            <div class="example-contents"><p>In application/modules/default/views/menu.phtml:</p></div>

            <pre class="programlisting brush: php">
foreach ($this-&gt;container as $page) {
    echo $this-&gt;navigation()-&gt;menu()-&gt;htmlify($page), PHP_EOL;
}
</pre>


            <div class="example-contents"><p>Output:</p></div>

            <pre class="programlisting brush: php">
&lt;a title=&quot;Go Home&quot; href=&quot;/&quot;&gt;Home&lt;/a&gt;
&lt;a href=&quot;/products&quot;&gt;Products&lt;/a&gt;
&lt;a title=&quot;About us&quot; href=&quot;/company/about&quot;&gt;Company&lt;/a&gt;
&lt;a href=&quot;/community&quot;&gt;Community&lt;/a&gt;
</pre>

        </div>
    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.sitemap"><div class="info"><h1 class="title">Sitemap Helper</h1></div>
        

        <p class="para">
            The Sitemap helper is used for generating <acronym class="acronym">XML</acronym> sitemaps, as
            defined by the <a href="http://www.sitemaps.org/protocol.php" class="link external">&raquo; Sitemaps <acronym class="acronym">XML</acronym>
                format</a>. Read more about <a href="http://en.wikipedia.org/wiki/Sitemaps" class="link external">&raquo; Sitemaps on Wikpedia</a>.
        </p>

        <p class="para">
            By default, the sitemap helper uses
            <a href="zend.validate.set.html#zend.validate.sitemap" class="link">sitemap validators</a>
            to validate each element that is rendered. This can be disabled by
            calling <code class="code">$helper-&gt;setUseSitemapValidators(false)</code>.
        </p>

        <blockquote class="note"><p><b class="note">Note</b>: 
            <p class="para">
                If you disable sitemap validators, the custom properties (see table)
                are not validated at all.
            </p>
        </p></blockquote>

        <p class="para">
            The sitemap helper also supports <a href="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" class="link external">&raquo; Sitemap XSD
                Schema</a> validation of the generated sitemap. This is disabled by default,
            since it will require a request to the Schema file. It can be
            enabled with
            <code class="code">$helper-&gt;setUseSchemaValidation(true)</code>.
        </p>

        <table id="zend.view.helpers.initial.navigation.sitemap.elements" class="doctable table"><div class="info"><caption><b>Sitemap XML elements</b></caption></div>
            

            
                <thead valign="middle">
                    <tr valign="middle">
                        <th>Element</th>
                        <th>Description</th>
                    </tr>

                </thead>


                <tbody valign="middle" class="tbody">
                    <tr valign="middle">
                        <td align="left"><code class="code">loc</code></td>

                        <td align="left">
                            Absolute <acronym class="acronym">URL</acronym> to page. An absolute
                            <acronym class="acronym">URL</acronym> will be generated by the helper.
                        </td>
                    </tr>


                    <tr valign="middle">
                        <td align="left"><code class="code">lastmod</code></td>

                        <td align="left">
                            <p class="para">
                                The date of last modification of the file, in <a href="http://www.w3.org/TR/NOTE-datetime" class="link external">&raquo; W3C Datetime</a>
                                format. This time portion can be omitted if desired, and only use
                                YYYY-MM-DD.
                            </p>

                            <p class="para">
                                The helper will try to retrieve the
                                <code class="code">lastmod</code> value from the page&#039;s
                                custom property <code class="code">lastmod</code> if it
                                is set in the page. If the value is not a
                                valid date, it is ignored.
                            </p>
                        </td>
                    </tr>


                    <tr valign="middle">
                        <td align="left"><code class="code">changefreq</code></td>

                        <td align="left">
                            <p class="para">
                                How frequently the page is likely to change.
                                This value provides general information to
                                search engines and may not correlate exactly
                                to how often they crawl the page. Valid
                                values are:
                            </p>

                            <ul class="itemizedlist">
                                <li class="listitem"><p class="para">always</p></li>
                                <li class="listitem"><p class="para">hourly</p></li>
                                <li class="listitem"><p class="para">daily</p></li>
                                <li class="listitem"><p class="para">weekly</p></li>
                                <li class="listitem"><p class="para">monthly</p></li>
                                <li class="listitem"><p class="para">yearly</p></li>
                                <li class="listitem"><p class="para">never</p></li>
                            </ul>

                            <p class="para">
                                The helper will try to retrieve the
                                <code class="code">changefreq</code> value from the page&#039;s
                                custom property <code class="code">changefreq</code> if it
                                is set in the page. If the value is not
                                valid, it is ignored.
                            </p>
                        </td>
                    </tr>


                    <tr valign="middle">
                        <td align="left"><code class="code">priority</code></td>

                        <td align="left">
                            <p class="para">
                                The priority of this <acronym class="acronym">URL</acronym> relative to other
                                <acronym class="acronym">URL</acronym>s on your site. Valid values range from
                                0.0 to 1.0.
                            </p>

                            <p class="para">
                                The helper will try to retrieve the
                                <code class="code">priority</code> value from the page&#039;s
                                custom property <code class="code">priority</code> if it
                                is set in the page. If the value is not
                                valid, it is ignored.
                            </p>
                        </td>
                    </tr>

                </tbody>
            
        </table>


        <p class="para">
            Methods in the sitemap helper:
        </p>

        <ul class="itemizedlist">
           <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}FormatOutput()</code> gets/sets a flag
                    indicating whether <acronym class="acronym">XML</acronym> output should be formatted. This
                    corresponds to the <code class="code">formatOutput</code> property
                    of the native <span class="classname">DOMDocument</span> class.
                    Read more at
                    <a href="http://php.net/domdocument" class="link external">&raquo; PHP: DOMDocument - Manual</a>.
                    Default is <b><tt>FALSE</tt></b>.
                </p>
           </li>

           <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}UseXmlDeclaration()</code> gets/sets a
                    flag indicating whether the <acronym class="acronym">XML</acronym> declaration should be
                    included when rendering. Default is <b><tt>TRUE</tt></b>.
                </p>
           </li>

           <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}UseSitemapValidators()</code> gets/sets a
                    flag indicating whether sitemap validators should be
                    used when generating the DOM sitemap. Default is
                    <b><tt>TRUE</tt></b>.
                </p>
           </li>

           <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}UseSchemaValidation()</code> gets/sets a
                    flag indicating whether the helper should use <acronym class="acronym">XML</acronym> Schema
                    validation when generating the DOM sitemap. Default is
                    <b><tt>FALSE</tt></b>. If <b><tt>TRUE</tt></b>.
                </p>
           </li>

           <li class="listitem">
                <p class="para">
                    <code class="code">{get|set}ServerUrl()</code> gets/sets server <acronym class="acronym">URL</acronym>
                    that will be prepended to non-absolute <acronym class="acronym">URL</acronym>s in the
                     <span class="methodname">url()</span> method. If no server <acronym class="acronym">URL</acronym> is
                    specified, it will be determined by the helper.
                </p>
           </li>

           <li class="listitem">
                <p class="para">
                     <span class="methodname">url()</span> is used to generate absolute
                    <acronym class="acronym">URL</acronym>s to pages.
                </p>
           </li>

           <li class="listitem">
                <p class="para">
                     <span class="methodname">getDomSitemap()</span> generates a DOMDocument
                    from a given container.
                </p>
           </li>
       </ul>

        <div class="example" id="zend.view.helpers.initial.navigation.sitemap.example"><div class="info"><p><b>Example #49 Rendering an XML sitemap</b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to render an <acronym class="acronym">XML</acronym> sitemap based
                on the setup we did further up.
            </p></div>

            <pre class="programlisting brush: php">
// In a view script or layout:

// format output
$this-&gt;navigation()
      -&gt;sitemap()
      -&gt;setFormatOutput(true); // default is false

// other possible methods:
// -&gt;setUseXmlDeclaration(false); // default is true
// -&gt;setServerUrl(&#039;http://my.otherhost.com&#039;);
// default is to detect automatically

// print sitemap
echo $this-&gt;navigation()-&gt;sitemap();
</pre>


            <div class="example-contents"><p>
                Notice how pages that are invisible or pages with
                <acronym class="acronym">ACL</acronym> roles incompatible with the view helper are filtered
                out:
            </p></div>

            <pre class="programlisting brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server/faq&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server/editions&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server/requirements&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/studio&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/studio/customers&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/prodcts/studio/support&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/about&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/about/investors&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/news&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/news/press&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/archive&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/community&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/community/account&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://forums.example.com/&lt;/loc&gt;
  &lt;/url&gt;
&lt;/urlset&gt;
</pre>


            <div class="example-contents"><p>
                Render the sitemap using no <acronym class="acronym">ACL</acronym> role (should filter out
                /community/account):
            </p></div>

            <pre class="programlisting brush: php">
echo $this-&gt;navigation()
          -&gt;sitemap()
          -&gt;setFormatOutput(true)
          -&gt;setRole();
</pre>


            <pre class="programlisting brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server/faq&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server/editions&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server/requirements&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/studio&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/studio/customers&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/prodcts/studio/support&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/about&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/about/investors&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/news&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/news/press&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/archive&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/community&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://forums.example.com/&lt;/loc&gt;
  &lt;/url&gt;
&lt;/urlset&gt;
</pre>


            <div class="example-contents"><p>
                Render the sitemap using a maximum depth of 1.
            </p></div>

            <pre class="programlisting brush: php">
echo $this-&gt;navigation()
          -&gt;sitemap()
          -&gt;setFormatOutput(true)
          -&gt;setMaxDepth(1);
</pre>


            <pre class="programlisting brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/server&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/products/studio&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/about&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/about/investors&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/company/news&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/community&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://www.example.com/community/account&lt;/loc&gt;
  &lt;/url&gt;
  &lt;url&gt;
    &lt;loc&gt;http://forums.example.com/&lt;/loc&gt;
  &lt;/url&gt;
&lt;/urlset&gt;
</pre>

        </div>

        <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>UTF-8 encoding used by default</b><br /></span>
            

            <p class="para">
                By default, Zend Framework uses <acronym class="acronym">UTF-8</acronym> as its default encoding,
                and, specific to this case, <span class="classname">Zend_View</span> does as well. Character
                encoding can be set differently on the view object itself using the
                 <span class="methodname">setEncoding()</span> method (or the the
                <var class="varname">encoding</var> instantiation parameter). However, since
                <span class="classname">Zend_View_Interface</span> does not define accessors for encoding,
                it&#039;s possible that if you are using a custom view implementation with the Dojo view
                helper, you will not have a  <span class="methodname">getEncoding()</span> method, which is
                what the view helper uses internally for determining the character set in which to
                encode.
            </p>

            <p class="para">
                If you do not want to utilize <acronym class="acronym">UTF-8</acronym> in such a situation, you will
                need to implement a  <span class="methodname">getEncoding()</span> method in your custom
                view implementation.
            </p>
        </p></blockquote>
    </div>

    <div class="section" id="zend.view.helpers.initial.navigation.navigation"><div class="info"><h1 class="title">Navigation Helper</h1></div>
        

        <p class="para">
            The Navigation helper is a proxy helper
            that relays calls to other navigational helpers. It can be
            considered an entry point to all navigation-related view tasks.
            The aforementioned navigational helpers are in the namespace
            <span class="classname">Zend_View_Helper_Navigation</span>, and would thus require
            the path <code class="code">Zend/View/Helper/Navigation</code> to be added as
            a helper path to the view. With the proxy helper residing in the
            <span class="classname">Zend_View_Helper</span> namespace, it will always be
            available, without the need to add any helper paths to the view.
        </p>

        <p class="para">
            The Navigation helper finds other helpers that implement the
            <span class="classname">Zend_View_Helper_Navigation_Helper</span>
            interface, which means custom view helpers can also be proxied.
            This would, however, require that the custom helper path is added
            to the view.
        </p>

        <p class="para">
            When proxying to other helpers, the Navigation helper can inject
            its container, <acronym class="acronym">ACL</acronym>/role, and translator. This means that you
            won&#039;t have to explicitly set all three in all navigational
            helpers, nor resort to injecting by means of
            <span class="classname">Zend_Registry</span> or static methods.
        </p>

        <ul class="itemizedlist">
           <li class="listitem">
               <p class="para">
                    <span class="methodname">findHelper()</span> finds the given helper,
                   verifies that it is a navigational helper, and injects
                   container, <acronym class="acronym">ACL</acronym>/role and translator.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                   <code class="code">{get|set}InjectContainer()</code> gets/sets a flag
                   indicating whether the container should be injected to
                   proxied helpers. Default is <b><tt>TRUE</tt></b>.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                   <code class="code">{get|set}InjectAcl()</code> gets/sets a flag
                   indicating whether the <acronym class="acronym">ACL</acronym>/role should be injected to
                   proxied helpers. Default is <b><tt>TRUE</tt></b>.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                   <code class="code">{get|set}InjectTranslator()</code> gets/sets a flag
                   indicating whether the translator should be injected to
                   proxied helpers. Default is <b><tt>TRUE</tt></b>.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                   <code class="code">{get|set}DefaultProxy()</code> gets/sets the default
                   proxy. Default is <code class="code">&#039;menu&#039;</code>.
               </p>
           </li>

           <li class="listitem">
               <p class="para">
                    <span class="methodname">render()</span> proxies to the render method of
                   the default proxy.
               </p>
           </li>
       </ul>
    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.tiny-src"><div class="info"><h1 class="title">TinySrc Helper</h1></div>
    

    <div class="section" id="zend.view.helpers.initial.tiny-src.intro"><div class="info"><h1 class="title">Overview</h1></div>
        

        <p class="para">
            <a href="http://tinysrc.net/" class="link external">&raquo; tinysrc.net</a> provides an API for automatic scaling
            and image format conversion for use with mobile devices. The API is quite simple: you
            simply create a standard HTML image tag, but append your image URL to a URL on the
            tinysrc.net domain:
        </p>

        <pre class="programlisting brush: html">
&lt;img src=&quot;http://i.tinysrc.net/http://yourdomain.com/images/foo.jpg&quot; /&gt;
</pre>


        <p class="para">
            Their service then sizes the image appropriately for the device requesting it.
        </p>

        <p class="para">
            You can control a number of aspects regarding image display, including:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Image dimensions</em>. You may specify a width and optional
                    height. These dimensions can be in absolute pixels, or use one of the adaptive
                    mechanisms tinysrc.net offers. One is <em class="emphasis">subtractive</em>;
                    prepending a dimension with a minus (&quot;-&quot;) indicates that the image should fill
                    the maximum physical dimensions, <em class="emphasis">minus</em> the value given in
                    pixels. The other is <em class="emphasis">percentage</em> based; prepending a
                    dimension with an &quot;x&quot; tells the service to size that dimension by that
                    percentage -- e.g., &quot;x20&quot; indicates &quot;20%&quot;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis">Image format</em>. By default, tinysrc.net autodiscovers the
                    format. Internally, it supports only <acronym class="acronym">JPEG</acronym> or
                    <acronym class="acronym">PNG</acronym>, and autoconverts <acronym class="acronym">GIF</acronym> to
                    <acronym class="acronym">PNG</acronym>. You can specifically request that it should convert an
                    image to either <acronym class="acronym">PNG</acronym> or <acronym class="acronym">JPEG</acronym>, however.
                </p>
            </li>
        </ul>

        <p class="para">
            The <span class="classname">TinySrc</span> view helper provides functionality around the
            tinysrc.net API, and gives you the ability to:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    selectively enable or disable whether it returns just the tinysrc.net URL or a
                    fully-populated HTML <acronym class="acronym">img</acronym> tag (enabled by default);
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    specify default values for image format as well as width and height;
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    specify a default value for the base URL used (uses the <a href="zend.view.helpers.html#zend.view.helpers.initial.baseurl" class="link">BaseUrl</a> view helper
                    by default);
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    override the default options on a per-image basis, via passed in options.
                </p>
            </li>
        </ul>
    </div>

    <div class="section" id="zend.view.helpers.initial.tiny-src.quick-start"><div class="info"><h1 class="title">Quick Start</h1></div>
        

        <p class="para">
            The most basic usage is simply to pass the path to an image, relative to your document
            root or base URL, to create the appropriate image tag:
        </p>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;tinySrc(&#039;/images/foo.png&#039;); ?&gt;
</pre>


        <p class="para">
            You may specify default values for the base URL, conversion format, dimensions, and
            whether or not to create an <acronym class="acronym">img</acronym> tag by default:
        </p>

        <pre class="programlisting brush: php">
&lt;?php $this-&gt;tinySrc()
           -&gt;setBaseUrl(&#039;http://example.com/foo/&#039;)
           -&gt;setCreateTag(false)                // disable tag creation
           -&gt;setDefaultFormat(&#039;png&#039;)            // convert images to PNG
           -&gt;setDefaultDimensions(&#039;-5&#039;, &#039;x20&#039;); // width should be 5 less than screen width;
                                                // height should be 20% of total screen height
?&gt;
</pre>


        <p class="para">
            Finally, you can also pass in values as an array of options, passed as the second
            parameter:
        </p>

        <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;tinySrc(&#039;/images/foo.png&#039;, array(
    &#039;format&#039; =&gt; &#039;jpg&#039;, // convert to JPEG
    &#039;width&#039;  =&gt; &#039;x50&#039;, // 1/2 screen width
); ?&gt;
</pre>

    </div>

    <div class="section" id="zend.view.helpers.initial.tiny-src.options"><div class="info"><h1 class="title">Configuration Options</h1></div>
        

        <dl>
<div class="info"><h1 class="title">TinySrc Helper Options</h1></div>
            

            <p class="para">
                The following options may be passed to the <var class="varname">$options</var> (second)
                argument of the helper.
            </p>

            <dt>

                <dt class="term">base_url</dt>

                <dd>

                    <p class="para">
                        The base URL, including scheme, host, and optionally port and/or path; this
                        value will be prepended to the image path provided in the first argument. By
                        default, this uses the <span class="classname">BaseUrl</span> and
                        <span class="classname">ServerUrl</span> view helpers to determine the value.
                    </p>
                </dd>

            </dt>


            <dt>

                <dt class="term">create_tag</dt>

                <dd>

                    <p class="para">
                        A boolean value indicating whether or not the helper should return an HTML
                        <acronym class="acronym">img</acronym> tag, or simply the tinysrc.net URL. By default, this
                        flag is enabled.
                    </p>
                </dd>

            </dt>


            <dt>

                <dt class="term">format</dt>

                <dd>

                    <p class="para">
                        Should be one of the values &quot;png&quot; or &quot;jpeg&quot;. If specified, this value will
                        be used to indicate the image conversion format. If not specified, the
                        default format will be used, or the format will be auto-determined based on
                        the image itself.
                    </p>
                </dd>

            </dt>


            <dt>

                <dt class="term">width</dt>

                <dd>

                    <p class="para">
                        This should be either <b><tt>null</tt></b>, or an integer (optionally
                        prefixed by &quot;x&quot; or &quot;-&quot;). If specified, this value will be used to determine
                        the converted image width. If null, neither a width nor a height value will
                        be used. If not specified, the default dimensions will be used.
                    </p>
                </dd>

            </dt>


            <dt>

                <dt class="term">height</dt>

                <dd>

                    <p class="para">
                        This should be either <b><tt>null</tt></b>, or an integer (optionally
                        prefixed by &quot;x&quot; or &quot;-&quot;). If specified, this value will be used to determine
                        the converted image height. If null, no height value will be used. If not
                        specified, the default height will be used.
                    </p>
                </dd>

            </dt>

        </dl>


        <p class="para">
            Any other options provided will be used as attributes to the HTML <acronym class="acronym">img</acronym>
            tag (if created).
        </p>
    </div>

    <div class="section" id="zend.view.helpers.initial.tiny-src.methods"><div class="info"><h1 class="title">Available Methods</h1></div>
        

        <dl>

            <dt id="zend.view.helpers.initial.tiny-src.methods.tiny-src">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">tinySrc</span>
                        <span class="methodparam">( 
                            <code_funcparams class="funcparams">$image = null, array $options = array()</code_funcparams>
                         )</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Called with no arguments, returns the helper instance. This is useful for
                        configuring the helper.
                    </p>

                    <p class="para">
                        If the <var class="varname">$image</var> argument is provided, it will either create and
                        return the tinysrc.net URL for the image, or an image tag containing that URL as
                        the source, depending on the status of the &quot;create tag&quot; flag (either the default
                        value, or the value passed via <var class="varname">$options</var>).
                    </p>

                    <p class="para">
                        See the <a href="zend.view.helpers.html#zend.view.helpers.initial.tiny-src.options" class="link">configuration
                            section</a> for details on the <var class="varname">$options</var> array.
                    </p>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.tiny-src.methods.set-base-url">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">setBaseUrl</span>
                        <span class="methodparam">( 
                            <code_funcparams class="funcparams">$url</code_funcparams>
                         )</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Use this method to manually specify the base URL to prepend to the
                        <var class="varname">$image</var> argument of the  <span class="methodname">tinySrc()</span>
                        method.
                    </p>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.tiny-src.methods.get-base-url">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">getBaseUrl</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Retrieve the base URL for prepending to image URLs. By default, autodiscovers
                        this from the <span class="classname">BaseUrl</span> and
                        <span class="classname">ServerUrl</span> view helpers.
                    </p>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.tiny-src.methods.set-default-format">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">setDefaultFormat</span>
                        <span class="methodparam">( 
                            <code_funcparams class="funcparams">$format = null</code_funcparams>
                         )</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Specifiy the default image conversion format. If none provided, the value is
                        cleared. Otherwise, expects either &quot;png&quot; or &quot;jpeg&quot;.
                    </p>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.tiny-src.methods.set-default-dimensions">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">setDefaultDimensions</span>
                        <span class="methodparam">( 
                            <code_funcparams class="funcparams">$width = null, $height = null</code_funcparams>
                         )</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Set the default dimensions for image conversion. If no <var class="varname">$width</var>
                        is specified, an empty value is provided for all dimensions (setting the height
                        requires a width as well). Passing no value for the height will set only a
                        width. Dimensions should be specified as either pixel dimensions, or:
                    </p>

                    <ul class="itemizedlist">
                        <li class="listitem">
                            <p class="para">
                                A pixel value, preceded by a &quot;-&quot; sign. This will indicate the width
                                should take the entire screen size, minus the number of pixels
                                specified.
                            </p>
                        </li>

                        <li class="listitem">
                            <p class="para">
                                A percentage of the total screen dimensions, expressed as &quot;x&quot; followed
                                by the percentage: &quot;x20&quot; is equivalent to 20%.
                            </p>
                        </li>
                    </ul>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.tiny-src.methods.set-create-tag">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">setCreateTag</span>
                        <span class="methodparam">( 
                            <code_funcparams class="funcparams">$flag</code_funcparams>
                         )</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Indicate whether the  <span class="methodname">tinySrc()</span> method should create an
                        HTML image tag. If boolean <b><tt>false</tt></b>, only a tinysrc.net URL
                        will be returned.
                    </p>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.tiny-src.methods.create-tag">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">createTag</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Returns the status of the &quot;create tag&quot; flag.
                    </p>
                </dd>

            </dt>

        </dl>

    </div>

    <div class="section" id="zend.view.helpers.initial.tiny-src.examples"><div class="info"><h1 class="title">Examples</h1></div>
        

        <div class="example" id="zend.view.helpers.initial.tiny-src.examples.url"><div class="info"><p><b>Example #50 Returning only a tinysrc.net URL</b></p></div>
            

            <div class="example-contents"><p>
                You may want to return only a tinysrc.net URL. To do this, you have two options:
                make this the default behavior, or specify in your <var class="varname">$options</var> not
                to create a tag.
            </p></div>

            <pre class="programlisting brush: php">
// Specifying default behavior:
$this-&gt;tinySrc()-&gt;setCreateTag(false);
echo $this-&gt;tinySrc(&#039;image.jpg&#039;);

// Per-image:
echo $this-&gt;tinySrc(&#039;image.jpg&#039;, array(&#039;create_tag&#039; =&gt; false));
</pre>

        </div>
    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.translate"><div class="info"><h1 class="title">Translate Helper</h1></div>
    

    <p class="para">
        Often web sites are available in several languages. To translate the
        content of a site you should simply use <a href="zend.translate.introduction.html" class="link">Zend_Translate</a> and to
        integrate <span class="classname">Zend_Translate</span> within your view you should use
        the <em class="emphasis">Translate</em> View Helper.
    </p>

    <p class="para">
        In all following examples we are using the simple Array Translation
        Adapter. Of course you can also use any instance of
        <span class="classname">Zend_Translate</span> and also any subclasses of
        <span class="classname">Zend_Translate_Adapter</span>. There are several ways to initiate
        the <em class="emphasis">Translate</em> View Helper:
    </p>

    <ul class="itemizedlist">
        <li class="listitem">
            <p class="para">
                Registered, through a previously registered instance in
                <span class="classname">Zend_Registry</span>
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                Afterwards, through the fluent interface
            </p>
        </li>

        <li class="listitem">
            <p class="para">
                Directly, through initiating the class
            </p>
        </li>
    </ul>

    <p class="para">
        A registered instance of <span class="classname">Zend_Translate</span> is the preferred
        usage for this helper. You can also select the locale to be used simply
        before you add the adapter to the registry.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: 
        <p class="para">
            We are speaking of locales instead of languages because a language
            also may contain a region. For example English is spoken in
            different dialects. There may be a translation for British and one
            for American English. Therefore, we say &quot;locale&quot; instead of
            &quot;language.&quot;
        </p>
    </p></blockquote>

    <div class="example" id="zend.view.helpers.initial.translate.registered"><div class="info"><p><b>Example #51 Registered instance</b></p></div>
        

        <div class="example-contents"><p>
            To use a registered instance just create an instance of
            <span class="classname">Zend_Translate</span> or <span class="classname">Zend_Translate_Adapter</span>
            and register it within <span class="classname">Zend_Registry</span> using
            <span class="classname">Zend_Translate</span> as its key.
        </p></div>

        <pre class="programlisting brush: php">
// our example adapter
$adapter = new Zend_Translate(
    array(
        &#039;adapter&#039; =&gt; &#039;array&#039;,
        &#039;content&#039; =&gt; array(&#039;simple&#039; =&gt; &#039;einfach&#039;),
        &#039;locale&#039;  =&gt; &#039;de&#039;
    )
);
Zend_Registry::set(&#039;Zend_Translate&#039;, $adapter);

// within your view
echo $this-&gt;translate(&#039;simple&#039;);
// this returns &#039;einfach&#039;
</pre>

    </div>

    <p class="para">
        If you are more familiar with the fluent interface, then you can also
        create an instance within your view and initiate the helper afterwards.
    </p>

    <div class="example" id="zend.view.helpers.initial.translate.afterwards"><div class="info"><p><b>Example #52 Within the view</b></p></div>
        

        <div class="example-contents"><p>
            To use the fluent interface, create an instance of
            <span class="classname">Zend_Translate</span> or <span class="classname">Zend_Translate_Adapter</span>,
            call the helper without a parameter, and call the
             <span class="methodname">setTranslator()</span> method.
        </p></div>

        <pre class="programlisting brush: php">
// within your view
$adapter = new Zend_Translate(
    array(
        &#039;adapter&#039; =&gt; &#039;array&#039;,
        &#039;content&#039; =&gt; array(&#039;simple&#039; =&gt; &#039;einfach&#039;),
        &#039;locale&#039;  =&gt; &#039;de&#039;
    )
);
$this-&gt;translate()-&gt;setTranslator($adapter)-&gt;translate(&#039;simple&#039;);
// this returns &#039;einfach&#039;
</pre>

    </div>

    <p class="para">
        If you are using the helper without <span class="classname">Zend_View</span> then you can
        also use it directly.
    </p>

    <div class="example" id="zend.view.helpers.initial.translate.directly"><div class="info"><p><b>Example #53 Direct usage</b></p></div>
        

        <pre class="programlisting brush: php">
// our example adapter
$adapter = new Zend_Translate(
    array(
        &#039;adapter&#039; =&gt; &#039;array&#039;,
        &#039;content&#039; =&gt; array(&#039;simple&#039; =&gt; &#039;einfach&#039;),
        &#039;locale&#039;  =&gt; &#039;de&#039;
    )
);

// initiate the adapter
$translate = new Zend_View_Helper_Translate($adapter);
print $translate-&gt;translate(&#039;simple&#039;); // this returns &#039;einfach&#039;
</pre>


        <div class="example-contents"><p>
            You would use this way if you are not working with
            <span class="classname">Zend_View</span> and need to create translated output.
        </p></div>
    </div>

    <p class="para">
        As already seen, the  <span class="methodname">translate()</span> method is used to return
        the translation. Just call it with the needed messageid of your
        translation adapter. But it can also replace parameters within the
        translation string. Therefore, it accepts variable parameters in two ways:
        either as a list of parameters, or as an array of parameters. As examples:
    </p>

    <div class="example" id="zend.view.helpers.initial.translate.parameter"><div class="info"><p><b>Example #54 Single parameter</b></p></div>
        

        <div class="example-contents"><p>
            To use a single parameter just add it to the method.
        </p></div>

        <pre class="programlisting brush: php">
// within your view
$date = &quot;Monday&quot;;
$this-&gt;translate(&quot;Today is %1\$s&quot;, $date);
// could return &#039;Heute ist Monday&#039;
</pre>

    </div>

    <blockquote class="note"><p><b class="note">Note</b>: 
        <p class="para">
            Keep in mind that if you are using parameters which are also text,
            you may also need to translate these parameters.
        </p>
    </p></blockquote>

    <div class="example" id="zend.view.helpers.initial.translate.parameterlist"><div class="info"><p><b>Example #55 List of parameters</b></p></div>
        

        <div class="example-contents"><p>
            Or use a list of parameters and add it to the method.
        </p></div>

        <pre class="programlisting brush: php">
// within your view
$date = &quot;Monday&quot;;
$month = &quot;April&quot;;
$time = &quot;11:20:55&quot;;
$this-&gt;translate(&quot;Today is %1\$s in %2\$s. Actual time: %3\$s&quot;,
                 $date,
                 $month,
                 $time);
// Could return &#039;Heute ist Monday in April. Aktuelle Zeit: 11:20:55&#039;
</pre>

    </div>

    <div class="example" id="zend.view.helpers.initial.translate.parameterarray"><div class="info"><p><b>Example #56 Array of parameters</b></p></div>
        

        <div class="example-contents"><p>
            Or use an array of parameters and add it to the method.
        </p></div>

        <pre class="programlisting brush: php">
// within your view
$date = array(&quot;Monday&quot;, &quot;April&quot;, &quot;11:20:55&quot;);
$this-&gt;translate(&quot;Today is %1\$s in %2\$s. Actual time: %3\$s&quot;, $date);
// Could return &#039;Heute ist Monday in April. Aktuelle Zeit: 11:20:55&#039;
</pre>

    </div>

    <p class="para">
        Sometimes it is necessary to change the locale of the translation. This
        can be done either dynamically per translation or statically for all
        following translations. And you can use it with both a parameter list
        and an array of parameters. In both cases the locale must be given as
        the last single parameter.
    </p>

    <div class="example" id="zend.view.helpers.initial.translate.dynamic"><div class="info"><p><b>Example #57 Change locale dynamically</b></p></div>
        

        <pre class="programlisting brush: php">
// within your view
$date = array(&quot;Monday&quot;, &quot;April&quot;, &quot;11:20:55&quot;);
$this-&gt;translate(&quot;Today is %1\$s in %2\$s. Actual time: %3\$s&quot;, $date, &#039;it&#039;);
</pre>

    </div>

    <p class="para">
        This example returns the Italian translation for the messageid. But it
        will only be used once. The next translation will use the locale from
        the adapter. Normally you will set the desired locale within the
        translation adapter before you add it to the registry. But you can also
        set the locale from within the helper:
    </p>

    <div class="example" id="zend.view.helpers.initial.translate.static"><div class="info"><p><b>Example #58 Change locale statically</b></p></div>
        

        <pre class="programlisting brush: php">
// within your view
$date = array(&quot;Monday&quot;, &quot;April&quot;, &quot;11:20:55&quot;);
$this-&gt;translate()-&gt;setLocale(&#039;it&#039;);
$this-&gt;translate(&quot;Today is %1\$s in %2\$s. Actual time: %3\$s&quot;, $date);
</pre>

    </div>

    <p class="para">
        The above example sets <em class="emphasis">&#039;it&#039;</em> as the new default locale which
        will be used for all further translations.
    </p>

    <p class="para">
        Of course there is also a  <span class="methodname">getLocale()</span> method to get the
        currently set locale.
    </p>

    <div class="example" id="zend.view.helpers.initial.translate.getlocale"><div class="info"><p><b>Example #59 Get the currently set locale</b></p></div>
        

        <pre class="programlisting brush: php">
// within your view
$date = array(&quot;Monday&quot;, &quot;April&quot;, &quot;11:20:55&quot;);

// returns &#039;de&#039; as set default locale from our above examples
$this-&gt;translate()-&gt;getLocale();

$this-&gt;translate()-&gt;setLocale(&#039;it&#039;);
$this-&gt;translate(&quot;Today is %1\$s in %2\$s. Actual time: %3\$s&quot;, $date);

// returns &#039;it&#039; as new set default locale
$this-&gt;translate()-&gt;getLocale();
</pre>

    </div>
</div>
        <div class="section" id="zend.view.helpers.initial.user-agent"><div class="info"><h1 class="title">UserAgent View Helper</h1></div>
    

    <div class="section" id="zend.view.helpers.initial.user-agent.intro"><div class="info"><h1 class="title">Overview</h1></div>
        

        <p class="para">
            This view helper provides the ability to inject and later retrieve a
            <span class="classname">Zend_Http_UserAgent</span> instance for use in branching display logic
            based on device capabilities.
        </p>
    </div>

    <div class="section" id="zend.view.helpers.initial.user-agent.quick-start"><div class="info"><h1 class="title">Quick Start</h1></div>
        

        <p class="para">
            In most cases, you can simply retrieve the User-Agent and related device by calling the
            helper. If the <span class="classname">UserAgent</span> was configured in the <a href="zend.application.available-resources.html#zend.application.available-resources.useragent" class="link">
            bootstrap</a>, that instance will be injected already in the helper; otherwise, it
            will instantiate one for you.
        </p>

        <pre class="programlisting brush: php">
&lt;?php if ($this-&gt;userAgent()-&gt;getDevice()-&gt;hasFlash()): ?&gt;
    &lt;object ...&gt;&lt;/object&gt;
&lt;?php endif ?&gt;
</pre>


        <p class="para">
            If you initialize the <span class="classname">UserAgent</span> object manually, you can still
            inject it into the helper, in one of two ways.
        </p>

        <pre class="programlisting brush: php">
// Pull the helper from the view, and inject:
$helper = $view-&gt;getHelper(&#039;userAgent&#039;);
$helper-&gt;setUserAgent($userAgent);

// Pass the UserAgent to the helper:
$view-&gt;userAgent($userAgent);
</pre>

    </div>

    <div class="section" id="zend.view.helpers.initial.user-agent.methods"><div class="info"><h1 class="title">Available Methods</h1></div>
        

        <dl>

            <dt id="zend.view.helpers.initial.user-agent.methods.user-agent">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">userAgent</span>
                        <span class="methodparam">( 
                            <code_funcparams class="funcparams">Zend_Http_UserAgent $userAgent = null</code_funcparams>
                         )</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Use this method to set or retrieve the <span class="classname">UserAgent</span>
                        instance. Passing an instance will set it; passing no arguments will retrieve
                        it. If no previous instance has been registered, one will be lazy-loaded using
                        defaults.
                    </p>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.user-agent.methods.set-user-agent">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">setUserAgent</span>
                        <span class="methodparam">( 
                            <code_funcparams class="funcparams">Zend_Http_UserAgent $userAgent</code_funcparams>
                         )</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        If you have an instance of the helper -- for instance, by calling the view
                        object&#039;s  <span class="methodname">getHelper()</span> method -- you may use this method
                        to set the <span class="classname">UserAgent</span> instance.
                    </p>
                </dd>

            </dt>


            <dt id="zend.view.helpers.initial.user-agent.methods.get-user-agent">
                <dt class="term">
                    <div class="methodsynopsis dc-description">
                         <span class="methodname">getUserAgent</span>
                    </div>

                </dt>

                <dd>

                    <p class="para">
                        Retrieves the <span class="classname">UserAgent</span> instance; if none is registered,
                        it will lazy-load one using default values.
                    </p>
                </dd>

            </dt>

        </dl>

    </div>
</div>
    </div>

    <div class="section" id="zend.view.helpers.paths"><div class="info"><h1 class="title">Localizando os Assistentes</h1></div>
        

        <p class="para">
            Assim como os scripts de visualização, seu controlador pode especificar uma lista de
            caminhos onde o <span class="classname">Zend_View</span> deve procurar pelas classes
            assistentes. Por padrão, <span class="classname">Zend_View</span> procura pelas classes
            assistentes em &quot;Zend/View/Helper/*&quot;. Você pode instruir o
            <span class="classname">Zend_View</span> a procurar em outros locais usando os métodos
             <span class="methodname">setHelperPath()</span> e  <span class="methodname">addHelperPath()</span>.
            Além disso, você pode indicar um prefixo da classe a ser usado para os assistentes no
            caminho fornecido, permitindo o uso de namespaces em suas classes assistentes. Por
            padrão, se nenhum prefixo da classe for fornecido, &#039;Zend_View_Helper_&#039; é assumido.
        </p>

        <pre class="programlisting brush: php">
$view = new Zend_View();

// Set path to /path/to/more/helpers, with prefix &#039;My_View_Helper&#039;
$view-&gt;setHelperPath(&#039;/path/to/more/helpers&#039;, &#039;My_View_Helper&#039;);
</pre>


        <p class="para">
            De fato, você pode &quot;empilhar&quot; caminhos usando o método
             <span class="methodname">addHelperPath()</span>. A medida que você adiciona caminhos à pilha,
            <span class="classname">Zend_View</span> procurará no caminho mais recentemente adicionado.
            Isto permite a você incrementar o conjunto original de assistentes (ou susbstituir) com
            os seus próprios personalizados.
        </p>

        <pre class="programlisting brush: php">
$view = new Zend_View();
// Add /path/to/some/helpers with class prefix &#039;My_View_Helper&#039;
$view-&gt;addHelperPath(&#039;/path/to/some/helpers&#039;, &#039;My_View_Helper&#039;);
// Add /other/path/to/helpers with class prefix &#039;Your_View_Helper&#039;
$view-&gt;addHelperPath(&#039;/other/path/to/helpers&#039;, &#039;Your_View_Helper&#039;);

// now when you call $this-&gt;helperName(), Zend_View will look first for
// &quot;/path/to/some/helpers/HelperName&quot; using class name
// &quot;Your_View_Helper_HelperName&quot;, then for
// &quot;/other/path/to/helpers/HelperName.php&quot; using class name
// &quot;My_View_Helper_HelperName&quot;, and finally for
// &quot;Zend/View/Helper/HelperName.php&quot; using class name
// &quot;Zend_View_Helper_HelperName&quot;.
</pre>

    </div>

    <div class="section" id="zend.view.helpers.custom"><div class="info"><h1 class="title">Escrevendo Assistentes Personalizados</h1></div>
        

        <p class="para">
            Escrever assistentes personalizados é fácil; basta seguir estas regras:
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    While not strictly necessary, we recommend either implementing
                    <span class="classname">Zend_View_Helper_Interface</span> or extending
                    <span class="classname">Zend_View_Helper_Abstract</span> when creating your
                    helpers. Introduced in 1.6.0, these simply define a
                     <span class="methodname">setView()</span> method; however, in upcoming releases, we
                    plan to implement a strategy pattern that will simplify much of
                    the naming schema detailed below. Building off these now will
                    help you future-proof your code.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The class name must, at the very minimum, end with the helper
                    name itself, using MixedCaps. E.g., if you were writing a
                    helper called &quot;specialPurpose&quot;, the class name would minimally
                    need to be &quot;SpecialPurpose&quot;. You may, and should, give the class
                    name a prefix, and it is recommended that you use &#039;View_Helper&#039;
                    as part of that prefix: &quot;My_View_Helper_SpecialPurpose&quot;. (You
                    will need to pass in the prefix, with or without the trailing
                    underscore, to  <span class="methodname">addHelperPath()</span> or
                     <span class="methodname">setHelperPath()</span>).
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    A classe deve ter um método público que coincida com o nome do assistente; este
                    é o método que será chamado quando o seu template chamar
                    &quot;$this-&gt;specialPurpose()&quot;. Em nosso exemplo &quot;specialPurpose&quot;, o método requerido
                    deverá ser declarado como &quot;public function specialPurpose()&quot;.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    Em geral, a classe não deve ecoar ou imprimir a saída gerada. Em lugar disso,
                    ela deve retornar os valores a serem impressos. Os valores retornados deverão
                    estar devidamente escapados.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    A classe deve estar em um arquivo chamado após a classe assistente. Voltando ao
                    exemplo &quot;specialPurpose&quot;, o arquivo recebeu o nome &quot;SpecialPurpose.php&quot;.
                </p>
            </li>
        </ul>

        <p class="para">
            Localize o arquivo com a classe assistente em algum dos caminhos armazenados na pilha,
            e o <span class="classname">Zend_View</span> automaticamente irá carregar, instanciar,
            persistir, e executar o código para você.
        </p>

        <p class="para">
            Aqui está um exemplo do assistente <span class="classname">SpecialPurpose</span>:
        </p>

        <pre class="programlisting brush: php">
class My_View_Helper_SpecialPurpose extends Zend_View_Helper_Abstract
{
    protected $_count = 0;
    public function specialPurpose()
    {
        $this-&gt;_count++;
        $output = &quot;I have seen &#039;The Jerk&#039; {$this-&gt;_count} time(s).&quot;;
        return htmlspecialchars($output);
    }
}
</pre>


        <p class="para">
            Em um script de visualização, você pode chamar o assistente
            <span class="classname">SpecialPurpose</span> quantas vezes desejar; ele será instanciado apenas
            uma vez; e persistirá durante todo o tempo de vida da instância de
            <span class="classname">Zend_View</span>.
        </p>

        <pre class="programlisting brush: php">
// remember, in a view script, $this refers to the Zend_View instance.
echo $this-&gt;specialPurpose();
echo $this-&gt;specialPurpose();
echo $this-&gt;specialPurpose();
</pre>


        <p class="para">
            A saída deverá se parecer com isto:
        </p>

        <pre class="programlisting brush: php">
I have seen &#039;The Jerk&#039; 1 time(s).
I have seen &#039;The Jerk&#039; 2 time(s).
I have seen &#039;The Jerk&#039; 3 time(s).
</pre>


        <p class="para">
            Sometimes you will need access to the calling <span class="classname">Zend_View</span>
            object -- for instance, if you need to use the registered encoding,
            or want to render another view script as part of your helper. To get
            access to the view object, your helper class should have a
             <span class="methodname">setView($view)</span> method, like the following:
        </p>

        <pre class="programlisting brush: php">
class My_View_Helper_ScriptPath
{
    public $view;

    public function setView(Zend_View_Interface $view)
    {
        $this-&gt;view = $view;
    }

    public function scriptPath($script)
    {
        return $this-&gt;view-&gt;getScriptPath($script);
    }
}
</pre>


        <p class="para">
            If your helper class has a  <span class="methodname">setView()</span> method, it will be
            called when the helper class is first instantiated, and passed the
            current view object. It is up to you to persist the object in your
            class, as well as determine how it should be accessed.
        </p>

        <p class="para">
            If you are extending <span class="classname">Zend_View_Helper_Abstract</span>, you do
            not need to define this method, as it is defined for you.
        </p>
    </div>

    <div class="section" id="zend.view.helpers.registering-concrete"><div class="info"><h1 class="title">Registering Concrete Helpers</h1></div>
        

        <p class="para">
            Sometimes it is convenient to instantiate a view helper, and then register it with the
            view. As of version 1.10.0, this is now possible using the
             <span class="methodname">registerHelper()</span> method, which expects two arguments: the
            helper object, and the name by which it will be registered.
        </p>

        <pre class="programlisting brush: php">
$helper = new My_Helper_Foo();
// ...do some configuration or dependency injection...

$view-&gt;registerHelper($helper, &#039;foo&#039;);
</pre>


        <p class="para">
            If the helper has a  <span class="methodname">setView()</span> method, the view object will call
            this and inject itself into the helper on registration.
        </p>

        <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Helper name should match a method</b><br /></span>
            

            <p class="para">
                The second argument to  <span class="methodname">registerHelper()</span> is the name of the
                helper. A corresponding method name should exist in the helper; otherwise,
                <span class="classname">Zend_View</span> will call a non-existent method when invoking the
                helper, raising a fatal <acronym class="acronym">PHP</acronym> error.
            </p>
        </p></blockquote>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.view.scripts.html">Scripts de Visualiza&ccedil;&atilde;o</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.view.html">Zend_View</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.view.abstract.html">Zend_View_Abstract</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.view.html">Zend_View</a></li>
  <li><a href="zend.view.introduction.html">Introdu&ccedil;&atilde;o</a></li>
  <li><a href="zend.view.controllers.html">Scripts Controladores</a></li>
  <li><a href="zend.view.scripts.html">Scripts de Visualiza&ccedil;&atilde;o</a></li>
  <li class="active"><a href="zend.view.helpers.html">Assistentes de Visualiza&ccedil;&atilde;o</a></li>
  <li><a href="zend.view.abstract.html">Zend_View_Abstract</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>